jest-community / jest-extended

Additional Jest matchers 🃏💪
https://jest-extended.jestcommunity.dev/
MIT License
2.31k stars 215 forks source link

TypeScript issue: File '/home/nmurgor/git/bitgesell-node-monitor/node_modules/jest-extended/types/index.d.ts' is not a module. #602

Open naftalimurgor opened 1 year ago

naftalimurgor commented 1 year ago

Bug

I get this warning when I use this package in a TypeScript project I am working on:

```bash
File '/home/nmurgor/git/jest-playground/node_modules/jest-extended/types/index.d.ts' is not a module.

What you did:

expect.extend(matchers);



What happened (please provide anything you think will help):

Description:

Possible solution:
The possible solution would be looking into `types/index.d.ts` and fixing the "non-module" warning by adding the appropriate exports
erunion commented 10 months ago

Seeing this as well with a simpler TS config.

File '/Users/erunion/code/node_modules/jest-extended/types/index.d.ts' is not a module.ts(2306)

import { toContainKey } from 'jest-extended';

expect.extend({ toContainKey });

__tests__/tsconfig.json:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "baseUrl": ".",
    "composite": true,
    "outDir": "./dist",
    "strict": true,
  },
  "include": ["**/*.ts", "**/*.js", "**/*.json", "../../global.d.ts"],
  "exclude": ["__tests__", "dist", "node_modules"]
}

tsconfig.base.json:

{
  "extends": "ts-node/node14/tsconfig.json",
  "ts-node": {
    "swc": true
  },
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "lib": ["ES2021"],
    "moduleResolution": "node",
    "noErrorTruncation": true,
    "noImplicitAny": false, // @todo Remove this when we enable strict mode.
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": false, // Not running in strict mode until we have better type safety .
    "target": "ES2021"
  }
}
naftalimurgor commented 10 months ago

You can post a repo,I think I managed to fix this but can't recall how. You may add a repository to reproduce then I can update with appropriate fix. Hint: fix probably in thetsconfig.json