-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a built-in helper type for dotted object path literals and path tuples #46337
Comments
See #39522 (comment):
|
I forgot to link #12290 and #20423. The former workshops implementing such a helper type (it's interesting to watch it evolve over the years as TS adds new features!) while the latter proposes a keyword. If a keyword is preferable, I wouldn't have a problem with that, but it sounds like that would have the same potential downsides (introducing naming conflicts with existing code) so there's probably no reason for that. I'm not sure what Ryan means when he says "required for declaration emit purposes" -- I was just hoping to see something like one of these, which were still being added as recently as v3.5. |
FWIW I’m also not sure about the “required for declaration emit purposes” comment, but to add a bit of context, I think the moment where we really started souring on adding more utility types was after we shipped |
Maybe the best way forward would be to double down on #20423? My main reason for wanting something built-in was that, unlike |
Suggestion
🔍 Search Terms
object key dotted path template literal helper type
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
I'd like to see a built-in helper type that takes an interface as a generic param, and returns either the union of all dotted-notation key paths, or tuples of valid paths:
📃 Motivating Example
Both of these notations are commonly used in libraries around the ecosystem. Many end users try to create similar complex types themselves, with results of varying quality, that may miss important edge cases or perform much worse than an optimal implementation would. I understand that there may have to be similar limitations on a built-in type, for recursive or excessively-deep inputs, but these could at least be thoughtfully designed and documented, with useful error messages.
💻 Use Cases
The text was updated successfully, but these errors were encountered: