Title: Named generics (or generic maps) for partial generic application (and inference for those that aren't passed) · Issue #42916 · microsoft/TypeScript · GitHub
Open Graph Title: Named generics (or generic maps) for partial generic application (and inference for those that aren't passed) · Issue #42916 · microsoft/TypeScript
X Title: Named generics (or generic maps) for partial generic application (and inference for those that aren't passed) · Issue #42916 · microsoft/TypeScript
Description: Suggestion 🔍 Search Terms #26242 Partial Generics Generic maps Generic objects Generic inference ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This w...
Open Graph Description: Suggestion 🔍 Search Terms #26242 Partial Generics Generic maps Generic objects Generic inference ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in ex...
X Description: Suggestion 🔍 Search Terms #26242 Partial Generics Generic maps Generic objects Generic inference ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change i...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42916
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Named generics (or generic maps) for partial generic application (and inference for those that aren't passed)","articleBody":"# Suggestion\r\n\r\n## 🔍 Search Terms\r\n\r\n- #26242\r\n- Partial Generics\r\n- Generic maps\r\n- Generic objects\r\n- Generic inference\r\n\r\n## ✅ Viability Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n\r\n## ⭐ Suggestion\r\n\r\nWe have all heard or seen this PR: #26242 which outlines the technical merits of allowing inference on some, but not all generics. What I am proposing **in addition to that core concept** is either\r\n- A new way of partially applying generics via an object-like syntax\r\n- Better support for generic inference in generic objects\r\n\r\n## 📃 Motivating Example\r\n\r\nHere is a tweet thread (with codesandbox examples) detailing some of the motivations for this feature: https://twitter.com/tannerlinsley/status/1363926547489456129\r\n\r\n## 💻 Use Cases\r\n\r\n- Allowing users to customize only **some** generics for a type or function without needing to know the **number of generics**, eg. no `LibraryType\u003c*, *, *, *, *, *, TData> // Oops! LibraryType expected 5 generic arguments, not 7.`\r\n- In the tweets and codesandboxes in that tweet, you can see some potential workarounds for allowing this type of behavior, but both are limited in either TS's ability to infer types nested in an object literal, or the ability for Ts to infer all generics after user-supplied ones (#26242 would fix this, but would still have the issue of `Type\u003c*,*,*,*,*,TDData>`)","author":{"url":"https://github.com/tannerlinsley","@type":"Person","name":"tannerlinsley"},"datePublished":"2021-02-22T19:32:12Z","url":"https://github.com/microsoft/TypeScript/issues/42916"}
| 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:9c0d51a0-0d73-6ac8-e1ef-b0658f06f59f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DEAE:2D40DE:27D6D50:32C68BB:6B01D8B4 |
| html-safe-nonce | 2b792ff173e515bea69f685b17efce1a27a3ae21c5f1374ff0aa4f73cd0047fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUFFOjJENDBERToyN0Q2RDUwOjMyQzY4QkI6NkIwMUQ4QjQiLCJ2aXNpdG9yX2lkIjoiNDkzNTE0ODQyNTQyMDMzMTE4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 12a6c5af90448b89a695626f553f036439597383f0e3387bc59f6a0064358673 |
| hovercard-subject-tag | issue:813797772 |
| 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/42916/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eebd83ff2f11ac7a916f16516e1b0a617af8852947ff92089881ae3d47d55807/microsoft/TypeScript/issues/42916 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eebd83ff2f11ac7a916f16516e1b0a617af8852947ff92089881ae3d47d55807/microsoft/TypeScript/issues/42916 |
| og:image:alt | Suggestion 🔍 Search Terms #26242 Partial Generics Generic maps Generic objects Generic inference ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in ex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tannerlinsley |
| 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