-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Search Terms
Template literal type annotation
π Version & Regression Information
- This is a crash
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about annotation / literal.
β― Playground Link
Playground link with relevant code (See console)
π» Code
import "reflect-metadata";
const formatMetadataKey = Symbol("format");
function format(formatString: string) {
return Reflect.metadata(formatMetadataKey, formatString);
}
class Greeter {
// Here : Can't use a literal type with an annotation
@format("Hello, %s")
greeting: `${string}`;
constructor() {
this.greeting = '#XXXX';
console.log('this.greeting', this.greeting);
}
}
new Greeter();π Actual behavior
When using a template literal type with an annotation I get the following error in the console :
Error: Debug Failure. Unexpected node.
Node TemplateLiteralType was unexpected
Because the template literal type is not currently supported :
TypeScript/src/compiler/transformers/ts.ts
Line 1541 in 68ff738
| return Debug.failBadSyntaxKind((node as LiteralTypeNode).literal); |
π Expected behavior
I should not get an error.
vladyslav-huba-lanars and a-tarasyuk
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueA PR has been opened for this issue