Closed
Description
TypeScript Version: 4.1.2
Search Terms:
template literal type template string interpolation number pixel value
Code
const pixelValue: number = 22;
type PixelValueType = `${number}px`;
const pixelString: PixelValueType = `22px`;
// Error here
const pixelStringWithTemplate: PixelValueType = `${pixelValue}px`;
Expected behavior:
A template string should be evaluated to determine if it matches a template literal type.
Actual behavior:
The template string is evaluated to type string
even though it can match the Template Literal Type
Type 'string' is not assignable to type '`${number}px`'.(2322)
Related Issues: