-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
TypeScript Version: 2.4.0
Code
let test: `a` | `b`Expected behavior:
test will be a variable of type "a" | "b", like when single quotes or double quotes are used.
Actual behavior:
It does not compile, giving various errors.
Justification:
We like to enforce the use of template strings instead of concatenation, but that leaves us with a mixture of backtick strings and either double or single quote strings. Ideally we would enforce just one type of quote throughout our projects and leave it at that. In order to utilize the power of template strings, we should obviously enforce only backticks for strings.
The problem now is that the compiler doesn't accurately parse strings delineated by backticks. When backtick delineated strings don't have any interpolation in them, the compiler should be able to recognize that they are just literal strings and should use them for type inference and everything else.