Skip to content

Commit 153666f

Browse files
authored
Add tests for export incorrectly emit twice for decorated class declaration (#8343) (#10651)
* Add tests and update baselines * Update baselines
1 parent f8d6e26 commit 153666f

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//// [tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts] ////
2+
3+
//// [0.ts]
4+
5+
export class base { }
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
8+
//// [2.ts]
9+
import {base} from "./0"
10+
import {foo} from "./0"
11+
12+
/* Comment on the Class Declaration */
13+
export class C extends base{
14+
constructor(@foo prop: any) {
15+
super();
16+
}
17+
}
18+
19+
//// [0.js]
20+
"use strict";
21+
var base = (function () {
22+
function base() {
23+
}
24+
return base;
25+
}());
26+
exports.base = base;
27+
function foo(target, propertyKey, parameterIndex) { }
28+
exports.foo = foo;
29+
//// [2.js]
30+
"use strict";
31+
var __extends = (this && this.__extends) || function (d, b) {
32+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
33+
function __() { this.constructor = d; }
34+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35+
};
36+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
37+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
38+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
39+
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;
40+
return c > 3 && r && Object.defineProperty(target, key, r), r;
41+
};
42+
var __param = (this && this.__param) || function (paramIndex, decorator) {
43+
return function (target, key) { decorator(target, key, paramIndex); }
44+
};
45+
var _0_1 = require("./0");
46+
var _0_2 = require("./0");
47+
/* Comment on the Class Declaration */
48+
var C = (function (_super) {
49+
__extends(C, _super);
50+
function C(prop) {
51+
_super.call(this);
52+
}
53+
return C;
54+
}(_0_1.base));
55+
C = __decorate([
56+
__param(0, _0_2.foo)
57+
], C);
58+
exports.C = C;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/conformance/decorators/class/constructor/0.ts ===
2+
3+
export class base { }
4+
>base : Symbol(base, Decl(0.ts, 0, 0))
5+
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
>foo : Symbol(foo, Decl(0.ts, 1, 21))
8+
>target : Symbol(target, Decl(0.ts, 2, 20))
9+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
10+
>propertyKey : Symbol(propertyKey, Decl(0.ts, 2, 35))
11+
>parameterIndex : Symbol(parameterIndex, Decl(0.ts, 2, 65))
12+
13+
=== tests/cases/conformance/decorators/class/constructor/2.ts ===
14+
import {base} from "./0"
15+
>base : Symbol(base, Decl(2.ts, 0, 8))
16+
17+
import {foo} from "./0"
18+
>foo : Symbol(foo, Decl(2.ts, 1, 8))
19+
20+
/* Comment on the Class Declaration */
21+
export class C extends base{
22+
>C : Symbol(C, Decl(2.ts, 1, 23))
23+
>base : Symbol(base, Decl(2.ts, 0, 8))
24+
25+
constructor(@foo prop: any) {
26+
>foo : Symbol(foo, Decl(2.ts, 1, 8))
27+
>prop : Symbol(prop, Decl(2.ts, 5, 16))
28+
29+
super();
30+
>super : Symbol(base, Decl(0.ts, 0, 0))
31+
}
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/conformance/decorators/class/constructor/0.ts ===
2+
3+
export class base { }
4+
>base : base
5+
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
8+
>target : Object
9+
>Object : Object
10+
>propertyKey : string | symbol
11+
>parameterIndex : number
12+
13+
=== tests/cases/conformance/decorators/class/constructor/2.ts ===
14+
import {base} from "./0"
15+
>base : typeof base
16+
17+
import {foo} from "./0"
18+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
19+
20+
/* Comment on the Class Declaration */
21+
export class C extends base{
22+
>C : C
23+
>base : base
24+
25+
constructor(@foo prop: any) {
26+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
27+
>prop : any
28+
29+
super();
30+
>super() : void
31+
>super : typeof base
32+
}
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @target: es5
2+
// @module: commonjs
3+
// @experimentaldecorators: true
4+
5+
// @Filename: 0.ts
6+
export class base { }
7+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
8+
9+
// @Filename: 2.ts
10+
import {base} from "./0"
11+
import {foo} from "./0"
12+
13+
/* Comment on the Class Declaration */
14+
export class C extends base{
15+
constructor(@foo prop: any) {
16+
super();
17+
}
18+
}

0 commit comments

Comments
 (0)