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
In the last design meeting, a few of us had an inclination to say "preserve the tag in template literals", but it was mixed.
Template literals can have two sorts of placeholders:
Generic: `hello ${ T }`
Non-generic:
`hello ${ string }`
`hello ${ string & { __tag: void } }`
That should afford you enough to know whether this type is instantiable... right?
Well....
`hello ${ string & { __tag: T } }`
Okay, we may be able to handle that...
Not necessarily easily...
We really don't want to descend and traverse the entire type.
It depends on the specific usage - the concept of being generic might be significant in two cases:
Can instantiation result in a different type? i.e. will instantiation actually replace some type variables?
Can instantiation also change the overall kind of type? (i.e. a union to a singleton type, conditional type to one of its branches, mapped types to a primitive, object, array...)
isGenericType really refers to the second.
So we should be able to get away with a change that says that `hello ${ string & { __tag: T } }` is not generic per se - it is not generic according to isGenericType.
Let's add that test case to the PR.
Is this the only place this could go wrong?
Wait what abut `hello ${ "world" & { __tag?: T } }` - can this be reduced?
Needs more discussion.
The text was updated successfully, but these errors were encountered:
Relating Methods With Generic Mapped Types
#56133
unknown[]
.Tightening Enum Assignability
#55915
#55924
Exporting
TypeChecker
'sisAssignableTo
Method#9879 (comment)
type
Import Gets Elided Even When Used in Export#56445
Fix Support for Intersections in Template Literal Types
#56434
`hello ${ T }`
`hello ${ string }`
`hello ${ string & { __tag: void } }`
`hello ${ string & { __tag: T } }`
isGenericType
really refers to the second.`hello ${ string & { __tag: T } }`
is not generic per se - it is not generic according toisGenericType
.`hello ${ "world" & { __tag?: T } }`
- can this be reduced?The text was updated successfully, but these errors were encountered: