feat(config): show warning message for nodejs ts target version mismatch#1678
feat(config): show warning message for nodejs ts target version mismatch#1678ahnpnl merged 1 commit intokulshekhar:masterfrom ahnpnl:feat-target-warning
Conversation
Pull Request Test Coverage Report for Build 4927
💛 - Coveralls |
|
I gety While my config is: Any idea how I could get past this? Is the use of "esnext" problematic? Edit: note that this is my main |
|
you can get pass the warning message by using the correct If you cannot change your |
|
I can confirm that this doesn't work with |
|
did you try clear cache ? Do you specify your extend tsconfig to |
|
Ok, it seems that it works when extending the base config, at lest I can't repro @merlinnot issue (having the right target but only in the base config, not the extended test config). So my initial issue seemed to happen when using "esnext". It won't tell that "esnext" is wrong, but only "undefined". I guess the warning message could be improved to tell whether no target is found, or the wrong target is found. Note that it indeed make sense to have a specific target for the test config, since Jest is a runtime environment on its own. |
|
PR to improve it is welcome :), the message is specified here. The code to use the message here The most common case I can see is with optional chaining. Some users come to ask the question why optional chaining doesn't work and turned out that they set the wrong |
|
Yeah weird, it shouldn't display "undefined" in this scenario according to your code. Anyway that's a edge case, thanks for the very quick answers! |
|
is it possible to turn of this warning? We have no problem with transpile to esnext on any project with ts-jest. Maybe because we use babel to do that job. |
|
Hi, I think it is a bug. It should only consider the case when users don’t use Babel. PR is welcome :) |
…1729) Fixes [undefined target](#1678 (comment)) Fixes [usage-with-Babel](#1678 (comment))
Summary
Often I see
ts-jestusers run into the problem and turned out that ones set thetargetversion in theirtsconfigto be incompatible with their NodeJs version. This can result in some features of TypeScript when transpiling tocommonjsaren't supported by a specific NodeJs version.This PR is to add a warning message for NodeJs 10/12 users that they should use recommended
targetby TypeScript team at https://github.com/microsoft/TypeScript/wiki/Node-Target-MappingTest plan
Added unit test and e2e test. Green CI
Does this PR introduce a breaking change?
Other information
Created a base jest config
jest-base.jsand e2e test as well as unit test config extend from it.Created a
tsconfig.spec.jsonto use for unit test/e2e test to speed up CI following the doc https://kulshekhar.github.io/ts-jest/user/config/isolatedModules#example-1