Warning when non-standard-name tsconfig file used - TS151001
See original GitHub issue🐛 Bug Report
Warning when non-standard-name tsconfig file is used.
This does not happen when using the standard tsconfig.json
file name.
➜ yarn test
yarn run v1.22.5
$ jest
ts-jest[config] (WARN) message TS151001: 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.
PASS ./main.test.ts
Something
✓ passes (2 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.715 s
Ran all test suites.
✨ Done in 2.57s.
To Reproduce
-
Init a project
npm init
-
Set node to latest LTS
echo v14.17.2 > .nvmrc
nvm install v14.17.2
nvm use
-
Install minimum set of latest packages (as of 05 Jul 2021)
yarn add -D typescript@4.3.4 jest@27.0.6 ts-jest@27.0.3 @types/jest@26.0.23
-
Create a test file with an always-true assertion
Example test file
main.test.ts
describe('Something', () => { it('passes', () => { expect(true).toEqual(true) }) })
-
Add test command to package.json scripts
"test": "jest"
-
Add non-standard-name tsconfig file with
"esModuleInterop": true
Example TSConfig file
tsconfig.test.json
{ "compilerOptions": { "target": "es6", "module": "commonjs", "rootDir": "./src", "strict": true, "noImplicitAny": true, "esModuleInterop": true } }
-
Add jest config referencing this tsconfig
Example Jest config file
jest.config.json
{ "preset": "ts-jest", "testEnvironment": "node", "globals": { "ts-jest": { "tsConfig": "./tsconfig.test.json" } } }
-
Reproduce
yarn test
Expected behavior
No warning:
➜ yarn test
yarn run v1.22.5
$ jest
PASS ./main.test.ts
Something
✓ passes (2 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.715 s
Ran all test suites.
✨ Done in 2.57s.
Link to repo (highly encouraged)
https://github.com/JamesPeiris/ts-jest-warning
Debug log:
Too big for Github comment character limit - pushed to the linked repo: https://github.com/JamesPeiris/ts-jest-warning/blob/master/ts-jest.log
Snippet:
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","version":"27.0.3"},"message":"babel is disabled","sequence":14,"time":"2021-07-05T11:43:10.158Z"}
{"context":{"diagnostics":{"exclude":[],"ignoreCodes":[6059,18002,18003],"pretty":true,"throws":true},"logLevel":20,"namespace":"config","package":"ts-jest","version":"27.0.3"},"message":"normalized diagnostics config via ts-jest option","sequence":15,"time":"2021-07-05T11:43:10.158Z"}
{"context":{"diagnosticCodes":[151001],"diagnosticText":"\u001b[94mmessage\u001b[0m\u001b[90m TS151001: \u001b[0mIf 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.\n","logLevel":20,"namespace":"TSError","package":"ts-jest","version":"27.0.3"},"message":"created new TSError","sequence":16,"time":"2021-07-05T11:43:10.165Z"}
{"context":{"error":{"diagnosticCodes":[151001],"diagnosticText":"\u001b[94mmessage\u001b[0m\u001b[90m TS151001: \u001b[0mIf 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.\n"},"logLevel":40,"namespace":"config","package":"ts-jest","version":"27.0.3"},"message":"\u001b[94mmessage\u001b[0m\u001b[90m TS151001: \u001b[0mIf 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.","sequence":17,"time":"2021-07-05T11:43:10.167Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","tsconfig":{"compileOnSave":false,"errors":[{"category":3,"code":151001,"messageText":"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."}],"fileNames":["/Users/james.peiris/Dev/ts-jest-warning/main.test.ts"],"options":{"allowSyntheticDefaultImports":true,"declaration":false,"inlineSourceMap":false,"inlineSources":true,"module":1,"noEmit":false,"removeComments":false,"sourceMap":true,"target":2},"raw":{"compileOnSave":false,"compilerOptions":{}},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{"/users/james.peiris/dev/ts-jest-warning":1}},"version":"27.0.3"},"message":"normalized typescript config via ts-jest option","sequence":18,"time":"2021-07-05T11:43:10.167Z"}
{"context":{"customTransformers":{"after":[],"afterDeclarations":[],"before":[{}]},"logLevel":20,"namespace":"config","package":"ts-jest","version":"27.0.3"},"message":"normalized custom AST transformers via ts-jest option","sequence":19,"time":"2021-07-05T11:43:10.168Z"}
{"context":{"cacheDirectory":"/private/var/folders/kj/22ywg46s75j72xsg2n1gxtt0_48bvj/T/jest_5mfnn5/ts-jest/0f/921a7d71e961b755b43a0d703c6193eb39e24d","logLevel":20,"namespace":"config","package":"ts-jest","version":"27.0.3"},"message":"will use file caching","sequence":20,"time":"2021-07-05T11:43:10.192Z"}
envinfo
System:
OS: Mac OSX 10.14.6 (Mojave)
Node version: 14.17.2
Npm packages:
jest: 27.0.6
ts-jest: 27.0.3
typescript: 4.3.4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5
Top GitHub Comments
@JamesPeiris Try using
tsconfig
with a lowercase ‘c’ instead oftsConfig
.The source code uses a
tsconfig
: https://github.com/kulshekhar/ts-jest/blob/master/src/types.ts#L66 While the docs usetsConfig
: https://huafu.github.io/ts-jest/user/config/tsConfigThe link to doc is not correct 😃 it should be https://kulshekhar.github.io/ts-jest