diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 8561db1c633ef..1b8970598689c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1511,6 +1511,7 @@ namespace ts { case SyntaxKind.BooleanKeyword: return factory.createIdentifier("Boolean"); + case SyntaxKind.TemplateLiteralType: case SyntaxKind.StringKeyword: return factory.createIdentifier("String"); diff --git a/tests/baselines/reference/decoratorOnClassProperty12.js b/tests/baselines/reference/decoratorOnClassProperty12.js new file mode 100644 index 0000000000000..a382229db5d44 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty12.js @@ -0,0 +1,28 @@ +//// [decoratorOnClassProperty12.ts] +declare function dec(): (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; +}()); diff --git a/tests/baselines/reference/decoratorOnClassProperty12.symbols b/tests/baselines/reference/decoratorOnClassProperty12.symbols new file mode 100644 index 0000000000000..2da0be023006b --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty12.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts === +declare function dec(): (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)) +} + diff --git a/tests/baselines/reference/decoratorOnClassProperty12.types b/tests/baselines/reference/decoratorOnClassProperty12.types new file mode 100644 index 0000000000000..cff46fbe4a94f --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassProperty12.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts === +declare function dec(): (target: any, propertyKey: string) => void; +>dec : () => (target: any, propertyKey: string) => void +>target : any +>propertyKey : string + +class A { +>A : A + + @dec() +>dec() : (target: any, propertyKey: string) => void +>dec : () => (target: any, propertyKey: string) => void + + foo: `${string}` +>foo : string +} + diff --git a/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts new file mode 100644 index 0000000000000..fb8841df243b4 --- /dev/null +++ b/tests/cases/conformance/decorators/class/property/decoratorOnClassProperty12.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @experimentaldecorators: true +// @emitdecoratormetadata: true +declare function dec(): (target: any, propertyKey: string) => void; + +class A { + @dec() + foo: `${string}` +}