vue-jest icon indicating copy to clipboard operation
vue-jest copied to clipboard

New tsconfig loading feature doesn't respect tsconfig extends

Open RhodeHummel opened this issue 2 years ago • 3 comments

The new tsconfig loading feature implemented in #471 doesn't properly support extended tsconfig files. For example take the following config for our test files that extends our base config:

tests/tsconfig.json

{
  "extends": "../tsconfig.json",
  "include": [
    "./**/*.ts"
  ],
}

tsconfig.json

{
  "compilerOptions": {
    /* shared compiler options set here */
  }
  "include": {
    "src/**/*.ts",
    "src/**/*.vue"
  }
}

When the tests are run the config that is loaded and passed to the typescript compiler doesn't include any of the options set in the base config even though tests/tsconfig.json properly extends it. Note this was working previously before this PR was merged.

It looks like this was an issue in the past as well but was fixed and now has appeared again. https://github.com/vuejs/vue-jest/issues/118 https://github.com/vuejs/vue-jest/pull/139

RhodeHummel avatar Aug 29 '22 18:08 RhodeHummel

I found a strange behaviour with tsconfig too.

I've added to jest config my tsconfig.spec.json that extends base tsconfig.json, and it works as I expected

globals: {
  'vue-jest': {
    tsConfig: './tsconfig.spec.json'
  }
}

christianopaets avatar Sep 17 '22 10:09 christianopaets

I can confirm that as well. Works with what @christianopaets showed together with copying compilerOptions of root config.

Rocik avatar Oct 07 '22 13:10 Rocik

I have also run into this same problem and wound up implementing my own vue-ts-transformer to override the vue-jest default handling for ts script blocks. My version is just using typescript.getParsedCommandLineOfConfigFile from the typescript library itself to load the config file, and passing the parsed config into typescript.transpileModule

I can see about putting up a PR to make that change upstream.

thebanjomatic avatar Oct 11 '22 17:10 thebanjomatic

Thanks @thebanjomatic @lmiller1990, v29.2.0 solved our issues with tsconfig extends !

Hyzual avatar Nov 03 '22 10:11 Hyzual