-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 3.4.3
Search Terms: backticks / literals / enums
Code
enum Foo {
hello = `foo`,
};Expected behavior:
It should work.
This is especially important because the backticks mode of the quotes rule from ESLint breaks programs (cf yarnpkg/berry#70 for an example). While it could be seen as an ESLint bug, I think it should be possible for TS to use raw template string interchangeably with regular strings as long as they don't contain variables.
Actual behavior:
It throws an error (type "foo" is not assignable to type 'Foo').
Playground Link:
Related Issues:
I think fixing this should have been part of #21476, but it focused on the case of "a" + "b" rather than the simpler case of a literal without variables.
sindresorhus, Tyler-Murphy, ksmith27, amcheshire, perryhealy and 6 more
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript