Open chwoerz opened 1 month ago
There are a few different stages of computation here:
--showConfig
shows you the computation at step 3, not step 4 or step 6. The intended use is figuring out what the "effective" tsconfig file you have is specifically in the case of figuring out what your extended tsconfigs are doing
Thanks for your response. But it does more. If you specify for example strict, then it will compute values because of this. So it should also show the moduleResolution if it's not the default even when no dependencies are set because dependencies could also be automatically computed.
I think noImplicitAny
etc showing up is the bug here, not the other way around. If showConfig
showed every default option it'd be way too big to comfortably read.
https://github.com/microsoft/TypeScript/pull/56701 is what changed showConfig to start showing some implied options; the code shown in the issue above is from that PR, so the fact that it's not working sounds like the bug to me, not that we're showing implied values.
@andrewbranch gets to drive this one to resolution then π
I don't know if it's a bug but I would want to see the whole config when I use showConfig and not only the properties which will be generated from my inputs but also the ones from the result.
So for example when I only set the target to nodenext I would want to see module to be set to nodenext too and moduleResolution to nodenext because of the computed module value.
This is working as I intended it to work... Implied and computed options are shown only if theyβre computed to be something other than the default. So "strict": true
expands out into everything else it implies, but an empty config doesnβt show you all the strict
flags set to false
. Showing every default would make the output of every --showConfig
102 lines.
So for example when I only set the target to nodenext I would want to see module to be set to nodenext too and moduleResolution to nodenext because of the computed module value.
nodenext
is not a value for target
, but I feel like itβs already doing what you want?
~/Developer/microsoft/eg/ts 1m 28s
β― cat tsconfig.json
{
"compilerOptions": {
"module": "NodeNext",
}
}
~/Developer/microsoft/eg/ts
β― tsc --version
Version 5.4.5
~/Developer/microsoft/eg/ts
β― tsc --showConfig -p tsconfig.json
{
"compilerOptions": {
"module": "nodenext",
"target": "esnext",
"moduleResolution": "nodenext",
"moduleDetection": "force",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"useDefineForClassFields": true
},
"files": []
}
You are right. Somehow I misread the code. I will create a small cli for myself to show me all the value which are at default.
I still have found an issue. When i only set
{
"compilerOptions": {
"module": "NodeNext"
}
}
Then I would think that it should create:
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"moduleDetection": "force",
"module": "nodenext",
"moduleResolution": "nodenext",
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
}
So resolveXy should also be shown as true.
But it only shows:
{
"compilerOptions": {
"module": "nodenext",
"target": "esnext",
"moduleResolution": "nodenext",
"moduleDetection": "force",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"useDefineForClassFields": true
}
}
But moduleResolution is `nodenext`. But this does not happen. So maybe we need to add the "module" dependency too.
π Search Terms
"showConfig result moduleResolution wrong"
π Version & Regression Information
β― Playground Link
No response
π» Code
tsconfig:
cli call:
tsc --showConfig
π Actual behavior
π Expected behavior
Wanted Output from
tsc --showConfig
Explanation
When we check utilities.ts: 8859
computedOptions
we can see, that this moduleResolution has the followingcomputeValue
functionality and that its not the default value because it depends on the computed module value which is, if not set,commonjs
.And in the compiler, it's used like this:
So there is no checking for if the
dependencies
are used. So this means that the default value will be used even if there is no dependency specified in the tsconfig.But in the showConfig code (commandLineParser.ts: 2565) we can see, that it checks if some of it's dependencies are there:
Suggestion
So I think the showConfig does not show the "real" values which are used during the execution of the code and I would suggest to change that to show all the properties if they have a value which is other than undefined.