Skip to content

Commit 3e9a9f7

Browse files
authored
refactor(compiler): improve error message for emit skipped (#2518)
1 parent 0320fb3 commit 3e9a9f7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/compiler/language-service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,10 @@ export const initializeLanguageServiceInstance = (configs: ConfigSet, logger: Lo
260260
}
261261
/* istanbul ignore next (this should never happen but is kept for security) */
262262
if (output.emitSkipped) {
263-
const message = interpolate(Errors.CannotProcessFile, { file: fileName })
264263
if (TS_TSX_REGEX.test(fileName)) {
265-
throw new Error(message)
264+
throw new Error(interpolate(Errors.CannotProcessFile, { file: fileName }))
266265
} else {
267-
logger.warn(message)
266+
logger.warn(interpolate(Errors.CannotProcessFileReturnOriginal, { file: fileName }))
268267

269268
return [code, '{}']
270269
}

src/utils/messages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const enum Errors {
1717
GotUnknownFileTypeWithBabel = 'Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files.',
1818
ConfigNoModuleInterop = 'If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.',
1919
MismatchNodeTargetMapping = 'There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping',
20-
CannotProcessFile = "Unable to process '{{file}}', falling back to original file content. Please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation",
20+
CannotProcessFileReturnOriginal = "Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`",
21+
CannotProcessFile = "Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}",
2122
}
2223

2324
/**

0 commit comments

Comments
 (0)