Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on TypeScript 4.4 #407

Open
hagevvashi opened this issue Sep 14, 2021 · 0 comments
Open

Error on TypeScript 4.4 #407

hagevvashi opened this issue Sep 14, 2021 · 0 comments

Comments

@hagevvashi
Copy link

hagevvashi commented Sep 14, 2021

TypeScript 4.4 breaking change causes below error.

Release blog doesn't tell this breaking change.

problem

error log

    Unexpected error(s) while parsing tsconfig (./tsconfig.json):

      No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.

jest.config.ts

import type { Config } from "@jest/types";

const config: Config.InitialOptions = {
  clearMocks: true,
  coverageDirectory: "<rootDir>/coverage/",
  collectCoverage: true,
  collectCoverageFrom: ["<rootDir>/**/*.{tsx,ts}"],
  coveragePathIgnorePatterns: [
    "<rootDir>/node_modules/",
    "<rootDir>/jest.config.ts",
  ],
  testMatch: ["**/?(*.)+(test).ts?(x)", "**/?(*.)+(test-d).ts?(x)"],
  transform: {
    "^.+\\.test-d.tsx?$": "dts-jest/transform",
    "^.+\\.[jt]sx?$": "babel-jest",
  },
  transformIgnorePatterns: ["<rootDir>/node_modules/"],
  globals: {
    _dts_jest_: {
      compiler_options: "./tsconfig.json",
      transpile: false,
    },
  },
};

export default config;

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNEXT",
    "module": "esnext",
    "moduleResolution": "node",
    "allowJs": false,
    "noEmit": false,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "declaration": true,
    "skipLibCheck": true,
    "strict": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedIndexedAccess": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true
  }
}

repo

https://github.com/hagevvashi/exp-dts-jest

cause of the problem

microsoft/TypeScript#44710 adds the call of directoryExists method.

https://github.com/microsoft/TypeScript/blob/40fa0c9f118aa1ed2b06ae0b3eed3946d5d2c612/src/compiler/utilities.ts#L6593

This PR makes ts.parseJsonConfigFileContent return above error and empty fileNames array.

workaround

The workaround is just changing the tsconfig.json path to the absolute one.

- compiler_options: "./tsconfig.json",
+ compiler_options: path.resolve(__dirname, "./tsconfig.json"), // we cannot use <rootDir> here

sample PR

hagevvashi/exp-dts-jest#1

resolution

I have no idea.

Is there anybody who has ideas for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant