Title: Make the type-level `typeof` aware of generic arguments · Issue #28931 · microsoft/TypeScript · GitHub
Open Graph Title: Make the type-level `typeof` aware of generic arguments · Issue #28931 · microsoft/TypeScript
X Title: Make the type-level `typeof` aware of generic arguments · Issue #28931 · microsoft/TypeScript
Description: The typeof on type-level is not aware of the generic type arguments. Consider: type ValueProducer
Open Graph Description: The typeof on type-level is not aware of the generic type arguments. Consider: type ValueProducer
X Description: The typeof on type-level is not aware of the generic type arguments. Consider: type ValueProducer<V> = (i? : V) => V function valueProducer<V>(i? : V) : V { return i } Intuitively, v...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/28931
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Make the type-level `typeof` aware of generic arguments","articleBody":"The `typeof` on type-level is not aware of the generic type arguments. Consider:\r\n\r\n```ts\r\ntype ValueProducer\u003cV> = (i? : V) => V\r\n\r\nfunction valueProducer\u003cV>(i? : V) : V {\r\n return i\r\n}\r\n```\r\nIntuitively, `valueProducer` has type of `ValueProducer` : `valueProducer : ValueProducer`, however, when we do:\r\n```ts\r\ntype T = typeof valueProducer\r\n```\r\nwe get this type back instead\r\n```ts\r\n\u003cV>(i?: V) => V\r\n```\r\nThe latter type is not generic, as there's no \"free\" type variables in it. \r\n\r\nIn other words, the `valueProducer\u003cV>` is an \"open\" generic type, that can be specialized by a single type argument. But the `typeof valueProducer` is a \"closed\" generic type, that can not be specialized.\r\n\r\n```ts\r\ntype T\u003cV> = typeof valueProducer\r\n\r\nlet a : T\u003cDate>\r\n\r\na.zxc // TS2339: Property 'zxc' does not exist on type '\u003cV>(i?: V) => V'\r\n\r\na().zxc // TS2339: Property 'zxc' does not exist on type '{}'\r\n\r\na().getTime() // TS2339: Property 'getTime' does not exist on type '{}'.\r\n```","author":{"url":"https://github.com/canonic-epicure","@type":"Person","name":"canonic-epicure"},"datePublished":"2018-12-09T12:54:20Z","url":"https://github.com/microsoft/TypeScript/issues/28931"}
| 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:c4b17c1a-83f4-c0e5-eba6-36eb423763a9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D950:B53AF:2C2EE74:3AE142C:6B01CB65 |
| html-safe-nonce | 44e59c4ebe5695e111217df122a31391cf809c8b4c648cc6c98653a71da80320 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTUwOkI1M0FGOjJDMkVFNzQ6M0FFMTQyQzo2QjAxQ0I2NSIsInZpc2l0b3JfaWQiOiI1NDE5ODUyOTM1MjI2MDUxNDI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 16999db1151ed711d6dd4ba02942f764d90a2f82cb8ffb4171367b2b4642ad4e |
| hovercard-subject-tag | issue:389019796 |
| 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/28931/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c21fbeea3c66969c130730623fc3c9d987fa3ab0aeddf79ee3a337a222cdaecf/microsoft/TypeScript/issues/28931 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c21fbeea3c66969c130730623fc3c9d987fa3ab0aeddf79ee3a337a222cdaecf/microsoft/TypeScript/issues/28931 |
| og:image:alt | The typeof on type-level is not aware of the generic type arguments. Consider: type ValueProducer |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | canonic-epicure |
| 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