Future-proof non-aliasing/always-expanding of mapped/intersection/union/etc. types #34556
Open
5 tasks done
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
Search Terms
non-aliasing types
Suggestion
I would like an "officially blessed" way to tell TS if it should give me a type alias, or give me an "expanded" type. (See examples)
Now that this issue has been fixed,
#32824
the technique I've been using to force TS to not alias a type will break when I migrate to TS 3.6/3.7
Use Cases
In some cases, seeing
Mapped1<T>/Intersected1<T>/Unioned1<T>
is better for a developer (see examples).In other cases, seeing the full "expanded" type is better (see examples for
Mapped2<T>/Intersected2<T>/Unioned2<T>
)Examples
Playground
Checklist
My suggestion meets these guidelines:
Related
#32824 (comment)
@weswigham brought up a different way to force TS to not alias a type.
I prefer my
Identity<T>
trick because it doesn't create a new "temporary" object type.The text was updated successfully, but these errors were encountered: