Skip to content

Commit 5915fbd

Browse files
committed
Adds minimal support for 'this' types in decorator metadata, emitting 'Object' for now.
1 parent 4be0095 commit 5915fbd

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6006,6 +6006,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
60066006
case SyntaxKind.UnionType:
60076007
case SyntaxKind.IntersectionType:
60086008
case SyntaxKind.AnyKeyword:
6009+
case SyntaxKind.ThisType:
60096010
break;
60106011

60116012
default:

tests/baselines/reference/decoratorMetadata.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ declare var decorator: any;
1212
class MyComponent {
1313
constructor(public Service: Service) {
1414
}
15+
16+
@decorator
17+
method(x: this) {
18+
}
1519
}
1620

1721
//// [service.js]
@@ -37,6 +41,14 @@ var MyComponent = (function () {
3741
function MyComponent(Service) {
3842
this.Service = Service;
3943
}
44+
MyComponent.prototype.method = function (x) {
45+
};
46+
__decorate([
47+
decorator,
48+
__metadata('design:type', Function),
49+
__metadata('design:paramtypes', [Object]),
50+
__metadata('design:returntype', void 0)
51+
], MyComponent.prototype, "method", null);
4052
MyComponent = __decorate([
4153
decorator,
4254
__metadata('design:paramtypes', [service_1.default])

tests/baselines/reference/decoratorMetadata.symbols

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ class MyComponent {
1919
>Service : Symbol(Service, Decl(component.ts, 6, 16))
2020
>Service : Symbol(Service, Decl(component.ts, 0, 6))
2121
}
22+
23+
@decorator
24+
>decorator : Symbol(decorator, Decl(component.ts, 2, 11))
25+
26+
method(x: this) {
27+
>method : Symbol(method, Decl(component.ts, 7, 5))
28+
>x : Symbol(x, Decl(component.ts, 10, 11))
29+
}
2230
}

tests/baselines/reference/decoratorMetadata.types

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ class MyComponent {
1919
>Service : Service
2020
>Service : Service
2121
}
22+
23+
@decorator
24+
>decorator : any
25+
26+
method(x: this) {
27+
>method : (x: this) => void
28+
>x : this
29+
}
2230
}

tests/cases/conformance/decorators/decoratorMetadata.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ declare var decorator: any;
1414
class MyComponent {
1515
constructor(public Service: Service) {
1616
}
17+
18+
@decorator
19+
method(x: this) {
20+
}
1721
}

0 commit comments

Comments
 (0)