vue-jest
vue-jest copied to clipboard
New tsconfig loading feature doesn't respect tsconfig extends
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
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'
}
}
I can confirm that as well.
Works with what @christianopaets showed together with copying compilerOptions
of root config.
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.
Thanks @thebanjomatic @lmiller1990, v29.2.0 solved our issues with tsconfig extends !