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
{{ message }}
Repository navigation
Cannot define a matching template literal type to a defined template literal Β #43143
changed the title [-]Cannot define a matching template literal type to a template literal in a function declaration[/-][+]Cannot define a matching template literal type to a defined template literal [/+]on Mar 8, 2021
We currently only produce template literal types from template literal expressions in as const contexts. We tried template literal types for all template literal expressions in #41891, but reverted it because it was too breaky. However, a happy medium would be to give template literal types to expressions that are contextually typed by string-like types. I can't imagine that breaking anything and it would solve this and other related issues.
Activity
[-]Cannot define a matching template literal type to a template literal in a function declaration[/-][+]Cannot define a matching template literal type to a defined template literal [/+]EdwardDrapkin commentedon Mar 8, 2021
It appears to happen in any case where there's a literal type, even the most trivial case fails:
RyanCavanaugh commentedon Mar 8, 2021
as constshouldn't be needed hereahejlsberg commentedon Mar 24, 2021
We currently only produce template literal types from template literal expressions in
as constcontexts. We tried template literal types for all template literal expressions in #41891, but reverted it because it was too breaky. However, a happy medium would be to give template literal types to expressions that are contextually typed by string-like types. I can't imagine that breaking anything and it would solve this and other related issues.