Skip to content

exclude type checking for files which matches with exclude option from tsconfig #2258

@changchangge

Description

@changchangge

TypeScript Version:4.1.3
ts-jest Version:26.4.4

Code

tsconfig.json

{
  "compilerOptions": {
    "sourceMap": false,
    "module": "commonjs", 
    "noImplicitAny": true, 
    "removeComments": false,
    "moduleResolution":"node",
    "baseUrl": ".",  
    "target": "es6", 
    "outDir": "./lib",
    "declaration": true,
    "strict": true,
  },
  "include": ["src"],
  "exclude": ["node_modules","tests"]
}

jest.config.js

module.exports = {
  roots: ['<rootDir>/tests'],
  globals: {
    'ts-jest': {
      tsconfig: 'tsconfig.json',
    },
  },
  transform: {
    '^.+\\.ts?$': 'ts-jest',
  },
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  testEnvironment: 'node',
  collectCoverageFrom: ['<rootDir>/src/**/*'],
  coveragePathIgnorePatterns: ['<rootDir>/node_modules', '<rootDir>/tests'],
  verbose: true,
};

When I run tsc, it is ok. But if I run jest to test,it is failed.

Expected behavior:

Avoid and exclude tests ts files.

Actual behavior:

It check ts files in the tests folder which has been excluded.

Workaround:

But if a restart VS then i will see the same behavior.

error:

● Test suite failed to run

tests/tag2.test.ts:5:22 - error TS7006: Parameter 'state' implicitly has an 'any' type.

Here is my project:
https://github.com/changchangge/simple-redux/tree/tag2

I hope that someone can help me , thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions