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
Template Literal Type - Does not evaluate interpolated template strings against type definition #41732
From #40707, if you use a const assertion the compiler will give a template literal type to a template literal expression, resulting in your desired behavior:
It looks like your desired behavior is for the compiler to always synthesize a template literal type for a template literal expression the way #10676 does for other literal types, so that as const is not necessary.
Reacted by William Cooter, Daniel Kezerashvili and Cesare Puliatti
From #40707, if you use a const assertion the compiler will give a template literal type to a template literal expression, resulting in your desired behavior:
It looks like your desired behavior is for the compiler to always synthesize a template literal type for a template literal expression the way #10676 does for other literal types, so that as const is not necessary.
Why the ${pixelValue}px cannot be inferred to PixelValueType automatically? It seems nothing problem.
Activity
jcalz commentedon Dec 1, 2020
Related issues: #40707, #10676
From #40707, if you use a
constassertion the compiler will give a template literal type to a template literal expression, resulting in your desired behavior:Playground link
It looks like your desired behavior is for the compiler to always synthesize a template literal type for a template literal expression the way #10676 does for other literal types, so that
as constis not necessary.a1245582339 commentedon Dec 3, 2020
Why the
${pixelValue}pxcannot be inferred to PixelValueType automatically? It seems nothing problem.RyanCavanaugh commentedon Dec 3, 2020
Anders Hejlsberg (@ahejlsberg) Seems like we should be providing a literal context here?
ahejlsberg commentedon Dec 7, 2020
This is a duplicate of #41631.
ahejlsberg commentedon Dec 9, 2020
Now implemented in #41891.