Title: Potentially wrong 'showConfig' results for default values, as it's used in the checker differently. · Issue #59442 · microsoft/TypeScript · GitHub
Open Graph Title: Potentially wrong 'showConfig' results for default values, as it's used in the checker differently. · Issue #59442 · microsoft/TypeScript
X Title: Potentially wrong 'showConfig' results for default values, as it's used in the checker differently. · Issue #59442 · microsoft/TypeScript
Description: 🔎 Search Terms "showConfig result moduleResolution wrong" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about showConfig ⏯ Playground Link No response 💻 Code tsconfig...
Open Graph Description: 🔎 Search Terms "showConfig result moduleResolution wrong" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about showConfig ⏯ Pla...
X Description: 🔎 Search Terms "showConfig result moduleResolution wrong" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about sh...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59442
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Potentially wrong 'showConfig' results for default values, as it's used in the checker differently.","articleBody":"### 🔎 Search Terms\r\n\r\n\"showConfig result moduleResolution wrong\"\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about showConfig\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\n_No response_\r\n\r\n### 💻 Code\r\n\r\ntsconfig:\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n }\r\n}\r\n```\r\n\r\ncli call:\r\n`tsc --showConfig`\r\n\r\n### 🙁 Actual behavior\r\n\r\n```json\r\n{ \r\n \"compilerOptions\": {}\r\n}\r\n```\r\n\r\n\r\n### 🙂 Expected behavior\r\n\r\n### Wanted Output from `tsc --showConfig`\r\n\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"moduleResolution\": \"Node10\",\r\n // And All other fields which have default values\r\n }\r\n}\r\n```\r\n\r\n### Explanation\r\nWhen we check utilities.ts: 8859 `computedOptions` we can see, that this moduleResolution has the following `computeValue` functionality and that its not the default value because it depends on the computed module value which is, if not set, `commonjs`. \r\n```typescript\r\n{\r\ndependencies: [\"module\", \"target\"],\r\n computeValue: (compilerOptions): ModuleResolutionKind =\u003e {\r\n let moduleResolution = compilerOptions.moduleResolution;\r\n if (moduleResolution === undefined) {\r\n switch (computedOptions.module.computeValue(compilerOptions)) {\r\n case ModuleKind.CommonJS:\r\n moduleResolution = ModuleResolutionKind.Node10;\r\n break;\r\n case ModuleKind.Node16:\r\n moduleResolution = ModuleResolutionKind.Node16;\r\n break;\r\n case ModuleKind.NodeNext:\r\n moduleResolution = ModuleResolutionKind.NodeNext;\r\n break;\r\n case ModuleKind.Preserve:\r\n moduleResolution = ModuleResolutionKind.Bundler;\r\n break;\r\n default:\r\n moduleResolution = ModuleResolutionKind.Classic;\r\n break;\r\n }\r\n }\r\n return moduleResolution;\r\n},\r\n }\r\n```\r\n\r\nAnd in the compiler, it's used like this: \r\n```typescript\r\nexport const getEmitModuleResolutionKind = computedOptions.moduleResolution.computeValue;\r\n// Usage:\r\ngetEmitModuleResolutionKind(compilerOptions)\r\n```\r\n\r\nSo 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. \r\n\r\nBut in the showConfig code (commandLineParser.ts: 2565) we can see, that it checks if some of it's dependencies are there:\r\n```typescript\r\nif (!providedKeys.has(option) \u0026\u0026 some(computedOptions[option as keyof typeof computedOptions].dependencies, dep =\u003e providedKeys.has(dep))) {\r\n```\r\n\r\n### Suggestion \r\nSo 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. \r\n\r\n\r\n\r\n","author":{"url":"https://github.com/chwoerz","@type":"Person","name":"chwoerz"},"datePublished":"2024-07-27T08:09:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/59442/TypeScript/issues/59442"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9d1fb620-6805-341f-fbfd-b4aa56dfe132 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 812E:40075:3FB26D:5B9F6E:6A622193 |
| html-safe-nonce | 398ce69bf41268414324d8f1b38b3f9fdb401cc843680e88b2930da68098109c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTJFOjQwMDc1OjNGQjI2RDo1QjlGNkU6NkE2MjIxOTMiLCJ2aXNpdG9yX2lkIjoiNDQ2MjIyODY1MzAyOTMzNTQ0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9bcceb19bc8086365f14a14821c605a11828f83695ce9c367010a41aacccd17e |
| hovercard-subject-tag | issue:2433359088 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/59442/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30f3fb31100ef52069635b80370e451b5572399b1c3229c67a03d7871a737f89/microsoft/TypeScript/issues/59442 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30f3fb31100ef52069635b80370e451b5572399b1c3229c67a03d7871a737f89/microsoft/TypeScript/issues/59442 |
| og:image:alt | 🔎 Search Terms "showConfig result moduleResolution wrong" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about showConfig ⏯ Pla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chwoerz |
| hostname | github.com |
| expected-hostname | github.com |
| None | be68eaf9abf2a202afbd94047d7200fb88b7edb0338f533bf171bbb1a69fab4e |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3d00b04c8874615454dfbdb32a7d2ca4db66d3f4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width