Title: Unresolved generic type arguments end up in type declarations since 5.7.2 · Issue #61338 · microsoft/TypeScript · GitHub
Open Graph Title: Unresolved generic type arguments end up in type declarations since 5.7.2 · Issue #61338 · microsoft/TypeScript
X Title: Unresolved generic type arguments end up in type declarations since 5.7.2 · Issue #61338 · microsoft/TypeScript
Description: 🔎 Search Terms unresolved, undefined, declarations 🕗 Version & Regression Information This changed between versions 5.6.3 and 5.7.2 In a project, I have a relatively complex set of generic types to be able to declare some values that get...
Open Graph Description: 🔎 Search Terms unresolved, undefined, declarations 🕗 Version & Regression Information This changed between versions 5.6.3 and 5.7.2 In a project, I have a relatively complex set of generic types to...
X Description: 🔎 Search Terms unresolved, undefined, declarations 🕗 Version & Regression Information This changed between versions 5.6.3 and 5.7.2 In a project, I have a relatively complex set of generic type...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/61338
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unresolved generic type arguments end up in type declarations since 5.7.2","articleBody":"### 🔎 Search Terms\n\nunresolved, undefined, declarations\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.6.3 and 5.7.2\n\nIn a project, I have a relatively complex set of generic types to be able to declare some values that get expanded and merged with defaults at runtime, while exposing that behavior in the type system. This seems to be complex enough that the semantic highlighting in VSCode regularly breaks in that file: https://github.com/zwave-js/zwave-js/blob/133172125d4148ea6e9e92a059b4325862ff6dd7/packages/cc/src/lib/Values.ts\n\nUntil TS 5.6.3, this code\n```ts\nexport const BasicCCValues = Object.freeze({\n\t...V.defineStaticCCValues(CommandClasses.Basic, {\n\t\t...V.staticProperty(\"currentValue\", {\n\t\t\t...ValueMetadata.ReadOnlyLevel,\n\t\t\tlabel: \"Current value\" as const,\n\t\t}),\n// ...\n});\n```\n\nwould result in a type definition like this:\n```ts\nexport declare const BasicCCValues: Readonly\u003c{\n currentValue: {\n readonly id: {\n commandClass: CommandClasses.Basic;\n property: \"currentValue\";\n };\n readonly endpoint: (endpoint?: number | undefined) => {\n readonly commandClass: CommandClasses.Basic;\n readonly endpoint: number;\n readonly property: \"currentValue\";\n };\n readonly is: (valueId: ValueID) => boolean;\n readonly meta: {\n readonly label: \"Current value\";\n readonly writeable: false;\n readonly max: 99;\n readonly min: 0;\n readonly type: \"number\";\n readonly readable: true;\n };\n readonly options: {\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n };\n };\n}>;\n```\n\nSince 5.7.2, this is what gets generated. Note that `ValueIDBase` and `TBlueprint` are generics type arguments used in the transformation that aren't defined in the output file, so the entire types of the `meta` and `options` properties effectively resolve to `any`. It seems that somewhere along the line, TS just gives up resolving:\n```ts\nexport declare const BasicCCValues: Readonly\u003c{\n currentValue: {\n readonly id: ValueIDBase;\n readonly endpoint: (endpoint?: number | undefined) => {\n readonly commandClass: CommandClasses.Basic;\n readonly endpoint: number;\n readonly property: \"currentValue\";\n };\n readonly is: (valueId: ValueID) => boolean;\n readonly meta: Readonly\u003c(ValueMetadata extends NonNullable\u003cTBlueprint[\"meta\"]> ? Readonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }> : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003cReadonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }>, (\"type\" | \"readable\" | \"writeable\") & keyof NonNullable\u003cTBlueprint[\"meta\"]>> & TBlueprint[\"meta\"]>) extends infer T ? { [K in keyof T as [undefined] extends [(ValueMetadata extends NonNullable\u003cTBlueprint[\"meta\"]> ? Readonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }> : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003cReadonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }>, (\"type\" | \"readable\" | \"writeable\") & keyof NonNullable\u003cTBlueprint[\"meta\"]>> & TBlueprint[\"meta\"]>)[K]] ? never : K]: (ValueMetadata extends NonNullable\u003cTBlueprint[\"meta\"]> ? Readonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }> : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003cReadonly\u003c{\n readonly type: \"any\";\n readonly readable: true;\n readonly writeable: true;\n }>, (\"type\" | \"readable\" | \"writeable\") & keyof NonNullable\u003cTBlueprint[\"meta\"]>> & TBlueprint[\"meta\"]>)[K]; } : never>;\n readonly options: Readonly\u003c(import(\"@zwave-js/cc\").CCValueOptions extends NonNullable\u003cTBlueprint[\"options\"]> ? {\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n } : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003c{\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n }, (\"stateful\" | \"secret\" | \"internal\" | \"minVersion\" | \"supportsEndpoints\" | \"autoCreate\") & keyof NonNullable\u003cTBlueprint[\"options\"]>> & TBlueprint[\"options\"]>) extends infer T ? { [K in keyof T as [undefined] extends [(import(\"@zwave-js/cc\").CCValueOptions extends NonNullable\u003cTBlueprint[\"options\"]> ? {\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n } : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003c{\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n }, (\"stateful\" | \"secret\" | \"internal\" | \"minVersion\" | \"supportsEndpoints\" | \"autoCreate\") & keyof NonNullable\u003cTBlueprint[\"options\"]>> & TBlueprint[\"options\"]>)[K]] ? never : K]: (import(\"@zwave-js/cc\").CCValueOptions extends NonNullable\u003cTBlueprint[\"options\"]> ? {\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n } : import(\"alcalzone-shared/types\").Simplify\u003cimport(\"alcalzone-shared/types\").Omit\u003c{\n readonly internal: false;\n readonly minVersion: 1;\n readonly secret: false;\n readonly stateful: true;\n readonly supportsEndpoints: true;\n readonly autoCreate: true;\n }, (\"stateful\" | \"secret\" | \"internal\" | \"minVersion\" | \"supportsEndpoints\" | \"autoCreate\") & keyof NonNullable\u003cTBlueprint[\"options\"]>> & TBlueprint[\"options\"]>)[K]; } : never>;\n };\n}>;\n```\n\n### ⏯ Playground Link\n\n_No response_\n\n### 💻 Code\n\n_No response_\n\n### 🙁 Actual behavior\n\nsee above\n\n### 🙂 Expected behavior\n\nsee above\n\n### Additional information about the issue\n\nI found another issue that might be related, but I'm not familiar enough with the details to know:\nhttps://github.com/microsoft/TypeScript/issues/60864","author":{"url":"https://github.com/AlCalzone","@type":"Person","name":"AlCalzone"},"datePublished":"2025-03-03T10:52:20Z","url":"https://github.com/microsoft/TypeScript/issues/61338"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:05197c19-56f6-d701-f5dd-2ccba6a2b822 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6C0:97D39:4F67FB:69125A:6B01CD83 |
| html-safe-nonce | 673a1696d63bf3c966efa210aac8daa1ee1ebca40bd58f333a4baaf64f6cc884 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkMwOjk3RDM5OjRGNjdGQjo2OTEyNUE6NkIwMUNEODMiLCJ2aXNpdG9yX2lkIjoiMTc2MDI4MjYxNDY0MjY0MDY3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0c998c9018ca7d705973fad66e06db179b65b7db5bd75ddd544efeaa709369aa |
| hovercard-subject-tag | issue:2890883049 |
| 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/61338/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e1d1ab07a5d5605757b80660162889bb4d64bae38fd8a0d901316283467630be/microsoft/TypeScript/issues/61338 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e1d1ab07a5d5605757b80660162889bb4d64bae38fd8a0d901316283467630be/microsoft/TypeScript/issues/61338 |
| og:image:alt | 🔎 Search Terms unresolved, undefined, declarations 🕗 Version & Regression Information This changed between versions 5.6.3 and 5.7.2 In a project, I have a relatively complex set of generic types to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlCalzone |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width