You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeA={[Pin `/${string}`]: string};typeB={[Pin'one'|'two'|'three']: number};typeC=A|B;// should not allow partial! But it is accepted, why?constbug1: C={one: 1};// should not be able to mix A and B! But it is accepted, why?constbug2: C={one: 1,'/hello': 'world'};
🙁 Actual behavior
Observe the mapped type A that uses a string template as an index, allowing only specific strings to be used as a key. When this type is used as part of a union, the resulting type exhibits behavior I found strange.
🙂 Expected behavior
I would expect the type assignment for bug1 and bug2 to not be permitted.
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
union template string literal unexpected behavior
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Observe the mapped type A that uses a string template as an index, allowing only specific strings to be used as a key. When this type is used as part of a union, the resulting type exhibits behavior I found strange.
🙂 Expected behavior
I would expect the type assignment for
bug1
andbug2
to not be permitted.The text was updated successfully, but these errors were encountered: