fix(46406): add Template Literal types to decorator metadata serialization (#46913)

This commit is contained in:
Oleksandr T
2022-01-12 21:34:00 -08:00
committed by GitHub
parent 461fb65623
commit 82377825d7
5 changed files with 72 additions and 0 deletions
+1
View File
@@ -1511,6 +1511,7 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
return factory.createIdentifier("Boolean");
case SyntaxKind.TemplateLiteralType:
case SyntaxKind.StringKeyword:
return factory.createIdentifier("String");
@@ -0,0 +1,28 @@
//// [decoratorOnClassProperty12.ts]
declare function dec(): <T>(target: any, propertyKey: string) => void;
class A {
@dec()
foo: `${string}`
}
//// [decoratorOnClassProperty12.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var A = /** @class */ (function () {
function A() {
}
__decorate([
dec(),
__metadata("design:type", String)
], A.prototype, "foo", void 0);
return A;
}());
@@ -0,0 +1,17 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : Symbol(dec, Decl(decoratorOnClassProperty12.ts, 0, 0))
>T : Symbol(T, Decl(decoratorOnClassProperty12.ts, 0, 25))
>target : Symbol(target, Decl(decoratorOnClassProperty12.ts, 0, 28))
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassProperty12.ts, 0, 40))
class A {
>A : Symbol(A, Decl(decoratorOnClassProperty12.ts, 0, 70))
@dec()
>dec : Symbol(dec, Decl(decoratorOnClassProperty12.ts, 0, 0))
foo: `${string}`
>foo : Symbol(A.foo, Decl(decoratorOnClassProperty12.ts, 2, 9))
}
@@ -0,0 +1,17 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : () => <T>(target: any, propertyKey: string) => void
>target : any
>propertyKey : string
class A {
>A : A
@dec()
>dec() : <T>(target: any, propertyKey: string) => void
>dec : () => <T>(target: any, propertyKey: string) => void
foo: `${string}`
>foo : string
}
@@ -0,0 +1,9 @@
// @target: es5
// @experimentaldecorators: true
// @emitdecoratormetadata: true
declare function dec(): <T>(target: any, propertyKey: string) => void;
class A {
@dec()
foo: `${string}`
}