right after installing jest the building throws a bunch of errors: file.d.ts' is not a module

Viewed 534

What exactly happen when installing jest in a nodejs-typescript-based project? Right after install jest (npm i -D jest @types/jest) the tsc throws a bunch of errors with the same message about my types (index.d.ts' is not a module):

jeff@jeff:~/my-app$ tsc
node_modules/@types/babel__core/index.d.ts:11:34 - error TS2306: File '/home/jeff/my-app/src/types/index.d.ts' is not a module.

11 import { GeneratorOptions } from '@babel/generator';
                                    ~~~~~~~~~~~~~~~~~~

node_modules/@types/babel__core/index.d.ts:12:31 - error TS2306: File '/home/jeff/my-app/src/types/index.d.ts' is not a module.

12 import { ParserOptions } from '@babel/parser';
                                 ~~~~~~~~~~~~~~~

node_modules/@types/babel__core/index.d.ts:13:22 - error TS2306: File '/home/jeff/my-app/src/types/index.d.ts' is not a module.

13 import template from '@babel/template';
                        ~~~~~~~~~~~~~~~~~
...s

Are there something wrong with my types declaration or about tsconfig.json? how could I fix it?

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ESNext"],
    "module": "commonjs",
    "allowJs": true,
    "outDir": "./build",
    "esModuleInterop": true,
    "paths": {
      "*": ["./src/types"]
    }
  },
  "include": ["app.ts", "src"],
  "exclude": [
    "**/*.spec.?s",
    "**/*.test.?s"
  ]
}

src/types/index.d.ts:

type Text = string;

app.ts:

const text: Text = 'ok'

console.log(text);
1 Answers
Related