question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. Init a project npm init

  2. Set node to latest LTS echo v14.17.2 > .nvmrc nvm install v14.17.2 nvm use

  3. 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

  4. Create a test file with an always-true assertion

    Example test file

    main.test.ts

    describe('Something', () => {
      it('passes', () => {
        expect(true).toEqual(true)
      })
    })
    
  5. Add test command to package.json scripts "test": "jest"

  6. 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
      }
    }
    
  7. 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"
        }
      }
    }
    
  8. 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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

2reactions
zachstencecommented, Jul 14, 2021

@JamesPeiris Try using tsconfig with a lowercase ‘c’ instead of tsConfig.

The source code uses a tsconfig: https://github.com/kulshekhar/ts-jest/blob/master/src/types.ts#L66 While the docs use tsConfig: https://huafu.github.io/ts-jest/user/config/tsConfig

1reaction
ahnpnlcommented, Jul 14, 2021

The link to doc is not correct 😃 it should be https://kulshekhar.github.io/ts-jest

Read more comments on GitHub >

github_iconTop Results From Across the Web

[tsc] Inform user when detected tsconfig.json file is not being ...
I'm requesting that the user be informed the detected tsconfig.json file is ... but maybe at least give a warning from the compiler...
Read more >
TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root ... These warnings are only about code which is provably...
Read more >
Is there a way to use --esModuleInterop in tsconfig as ...
Yes, do "esModuleInterop": true in your tsconfig.json. For every flag option that can be passed to the CLI, the same can usually be...
Read more >
Configuring TSLint - Palantir Open Source
When using the CLI or many third-party tools, a file named tslint.json or tslint.yaml is used to configure which rules get run and...
Read more >
Understanding TypeScript Configuration Options
TypeScript. This post will walk you through how tsconfig.json works in your application with some examples. Example Repo. Here is a link to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found