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 :
|
return Debug.failBadSyntaxKind((node as LiteralTypeNode).literal); |
π Expected behavior
I should not get an error.
Bug Report
π Search Terms
Template literal type annotation
π Version & Regression Information
β― Playground Link
Playground link with relevant code (See console)
π» Code
π Actual behavior
When using a template literal type with an annotation I get the following error in the console :
Because the template literal type is not currently supported :
TypeScript/src/compiler/transformers/ts.ts
Line 1541 in 68ff738
π Expected behavior
I should not get an error.