Title: Separate type application from function application · Issue #29043 · microsoft/TypeScript · GitHub
Open Graph Title: Separate type application from function application · Issue #29043 · microsoft/TypeScript
X Title: Separate type application from function application · Issue #29043 · microsoft/TypeScript
Description: As discussed in #28931, currently the type application for the function with generic parameters is tied to that function application. Specialize the value of the function with generics is only possible during the call. So the following c...
Open Graph Description: As discussed in #28931, currently the type application for the function with generic parameters is tied to that function application. Specialize the value of the function with generics is only poss...
X Description: As discussed in #28931, currently the type application for the function with generic parameters is tied to that function application. Specialize the value of the function with generics is only poss...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29043
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Separate type application from function application","articleBody":"As discussed in #28931, currently the type application for the function with generic parameters is tied to that function application. \r\n\r\nSpecialize the value of the function with generics is only possible during the call. So the following compiles fine:\r\n```ts\r\nfunction id\u003cV> (v : V) { return v }\r\n\r\nconst some : Date = id\u003cDate>(new Date())\r\n```\r\nBut this does not:\r\n```ts\r\nfunction id\u003cV> (v : V) { return v }\r\n\r\ntype IdDate = typeof id\u003cDate> // TS1005: ';' expected \r\n\r\nconst dateId = id\u003cDate> // TS1109: Expression expected.\r\n```\r\nIt would be very beneficial to separate type application from function application. For example (the original reason of this request), it will allow mixins with generic parameters:\r\n```ts\r\nexport type Constructable\u003cT extends any> = new (...args : any[]) => T\r\nexport type AnyFunction = (...input: any[]) => any\r\nexport type Mixin\u003cT extends AnyFunction> = InstanceType\u003cReturnType\u003cT>>\r\n\r\nexport const Atom = \u003cV, T extends Constructable\u003cObject>>(base : T) =>\r\n\r\nclass Atom extends base {\r\n value : V\r\n\r\n hasValue () : boolean {\r\n return this.hasOwnProperty('value')\r\n }\r\n}\r\n\r\nexport type Atom = Mixin\u003ctypeof Atom> // this currently works, but does not have generic argument\r\n\r\nexport type Atom\u003cV> = Mixin\u003ctypeof Atom\u003cV>> // this is the goal\r\n```\r\n","author":{"url":"https://github.com/canonic-epicure","@type":"Person","name":"canonic-epicure"},"datePublished":"2018-12-15T09:07:06Z","url":"https://github.com/microsoft/TypeScript/issues/29043"}
| 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:9649d97c-3f73-397b-8d03-be85810509e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BE0:ADA9D:339D2C1:4239183:6B01D115 |
| html-safe-nonce | a5b9d730980487d3b6c525a803dccfa16dd3d9762b4e2aa9bdf21830bae82f99 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkUwOkFEQTlEOjMzOUQyQzE6NDIzOTE4Mzo2QjAxRDExNSIsInZpc2l0b3JfaWQiOiIxNTYzMTk2ODU3MTkzMTg5NjUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7a84cd5c16474e12eee65a0bfeafea5c81bc0e3a81382ead2d056762af56cfc8 |
| hovercard-subject-tag | issue:391359779 |
| 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/29043/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7a941ff4ff836725ff4063e756afc0e9a03029119d132c4c10d3149ba038e5e0/microsoft/TypeScript/issues/29043 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7a941ff4ff836725ff4063e756afc0e9a03029119d132c4c10d3149ba038e5e0/microsoft/TypeScript/issues/29043 |
| og:image:alt | As discussed in #28931, currently the type application for the function with generic parameters is tied to that function application. Specialize the value of the function with generics is only poss... |
| 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