Title: instantiation expression usage leading to an invalid d.ts file generation · Issue #60758 · microsoft/TypeScript · GitHub
Open Graph Title: instantiation expression usage leading to an invalid d.ts file generation · Issue #60758 · microsoft/TypeScript
X Title: instantiation expression usage leading to an invalid d.ts file generation · Issue #60758 · microsoft/TypeScript
Description: 🔎 Search Terms partial function generic application, function generic variant from another function, instantiation-expressions 🕗 Version & Regression Information This changed between versions 5.6.2 and 5.7.2 ⏯ Playground Link https://www...
Open Graph Description: 🔎 Search Terms partial function generic application, function generic variant from another function, instantiation-expressions 🕗 Version & Regression Information This changed between versions 5.6.2...
X Description: 🔎 Search Terms partial function generic application, function generic variant from another function, instantiation-expressions 🕗 Version & Regression Information This changed between versions 5...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60758
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"instantiation expression usage leading to an invalid d.ts file generation","articleBody":"### 🔎 Search Terms\n\npartial function generic application, function generic variant from another function, instantiation-expressions\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.6.2 and 5.7.2\n\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.7.2#code/C4TwDgpgBAyg9gWwgBQE50q0BpCIDOUAvFAEoQCGAJnAHYA2IAgqqhSADxoYRYi4gAfAChQkKE2AcmUCAA9gEWlULlqdRizacArrQDWtOAHdaggDRQAkrIVKVUWjoQAjXsUfO3qQR6YBtKwBdYWF5MDgsKAAzPQBjYABLOigECkTaAQBxHQpUKg5hKChsW0VlQlRKGgYQKH9uTBw8SwA6dvgkRt5mgiDzYUEACiKofTx8AC4SgYBKaY4AFTL7QjgXACsIBOHRgDcKeh0IacW54l8Do+hEwgBRBTYEpctyOMiCyQ5sSwAGCygekMJjMvgA3qMqsAdKhaFAlisKlB1lsdiNisUrsdTgNivMoFibvdHhRnmcyNsPtIpD8oP9LECjKZBL4iODRsUoTC4eMCP5fkEoBkCYdjqMAL7CSWicDQABicDgHjBMUVAEZpvhgKgMgBzSzRRUAJk12r1UElYmgACE8sqoC48hqoFqdbR9Q68iaXWb3RaZeIFXBbagPEGoAAfKAh4TvWhaz2oASEEj+ADkjtQarTlgzXrTgoohDjWrCcgiURLwCF+BDHjSGWyuXyQ0zydmHCDIZEoSAA\n\n### 💻 Code\n\n```ts\ntype SomePropertyKeys = ReadonlyArray\u003cPropertyKey>\ntype At\u003cA extends ReadonlyArray\u003cunknown>, I extends number = number> = A[I]\n\nexport function mainKeyGuard\u003c\n K extends readonly [PropertyKey, ...SomePropertyKeys],\n>(\n keys: K,\n): \u003cT extends object>(\n value: T,\n) => value is Extract\u003cT, Record\u003cAt\u003cK, 0>, unknown>> {\n return \u003cT extends object>(\n value: T,\n ): value is Extract\u003cT, Record\u003cAt\u003cK, 0>, unknown>> => {\n return keys[0] in value\n }\n}\n\ntype Foo = { foo1: string, foo2: string }\ntype Bar = { bar1: string, bar2: string }\ntype FooBar = Foo | Bar\nconst barKeys = ['bar1', 'bar2'] as const\nexport const isBar = mainKeyGuard(barKeys)\u003cFooBar>\n```\n\n\n### 🙁 Actual behavior\n\nStarting with the v5.7.2, the generated d.ts file declares `isBar` as a function which reference a missing generic type T, so an error is raised\n```ts\nexport declare const isBar: (value: FooBar) => value is Extract\u003cT, Record\u003cAt\u003cK, 0>, unknown>>;\n```\n\n### 🙂 Expected behavior\n\nI would expect the `isBar` function d.ts declaration to not reference a missing generic type T.\nPreviously, the generated d.ts file behaved like the following\n```ts\nexport declare const isBar: (value: FooBar) => value is Bar;\n```\n\n### Additional information about the issue\n\nThe title mentions \"instantiation expression\" but I'm not totally sure about how the involved feature is actually named ","author":{"url":"https://github.com/AlexisTessier","@type":"Person","name":"AlexisTessier"},"datePublished":"2024-12-13T15:21:33Z","url":"https://github.com/microsoft/TypeScript/issues/60758"}
| 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:fc9c3091-c230-3cdb-a503-af564409b7e5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A174:1F2F:10B7C29:1643ACC:6B01CD1F |
| html-safe-nonce | 2756b5f98bc9beab9c34f418cbf29f21db1428d39ebc142b705b06327a0f2845 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTc0OjFGMkY6MTBCN0MyOToxNjQzQUNDOjZCMDFDRDFGIiwidmlzaXRvcl9pZCI6IjcxODU0Mzk2NDA0MzI3OTA4MTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b944c7e531f2704d1be01ac2afd70a929ebfc0a6ec84a5cb1dc6e4bd5c63f9b0 |
| hovercard-subject-tag | issue:2738635215 |
| 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/60758/issue_layout |
| twitter:image | https://opengraph.githubassets.com/293d2ff173b6708dcffa287d320e40af30caaf769ce51c438793ddec87376461/microsoft/TypeScript/issues/60758 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/293d2ff173b6708dcffa287d320e40af30caaf769ce51c438793ddec87376461/microsoft/TypeScript/issues/60758 |
| og:image:alt | 🔎 Search Terms partial function generic application, function generic variant from another function, instantiation-expressions 🕗 Version & Regression Information This changed between versions 5.6.2... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexisTessier |
| 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