Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): return original file content and show warning on emit skip #2410

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler/ts-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ export class TsCompiler implements TsCompilerInstance {
this._doTypeChecking(fileName)
/* istanbul ignore next (this should never happen but is kept for security) */
if (output.emitSkipped) {
throw new Error(interpolate(Errors.CannotCompile, { file: fileName }))
this._logger.warn(interpolate(Errors.CannotProcessFile, { file: fileName }))

return fileContent
}
// Throw an error when requiring `.d.ts` files.
if (!output.outputFiles.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const enum Errors {
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.',
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.',
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',
CannotCompile = "Unable to process '{{file}}'. Please make sure that `outDir` in your tsconfig is neither `''` or `'.'`.",
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",
}

/**
Expand Down