-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform decorators that reference private names into a 'static {}' …
…block (#50074)
- Loading branch information
Showing
13 changed files
with
508 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/decoratorOnClassMethod19(target=es2015).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//// [decoratorOnClassMethod19.ts] | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
|
||
class C1 { | ||
#x | ||
|
||
@decorator((x: C1) => x.#x) | ||
y() {} | ||
} | ||
|
||
class C2 { | ||
#x | ||
|
||
y(@decorator((x: C2) => x.#x) p) {} | ||
} | ||
|
||
|
||
//// [decoratorOnClassMethod19.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 __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _C1_x, _C2_x; | ||
class C1 { | ||
constructor() { | ||
_C1_x.set(this, void 0); | ||
} | ||
y() { } | ||
} | ||
_C1_x = new WeakMap(); | ||
(() => { | ||
__decorate([ | ||
decorator((x) => __classPrivateFieldGet(x, _C1_x, "f")), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], C1.prototype, "y", null); | ||
})(); | ||
class C2 { | ||
constructor() { | ||
_C2_x.set(this, void 0); | ||
} | ||
y(p) { } | ||
} | ||
_C2_x = new WeakMap(); | ||
(() => { | ||
__decorate([ | ||
__param(0, decorator((x) => __classPrivateFieldGet(x, _C2_x, "f"))), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], C2.prototype, "y", null); | ||
})(); |
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/decoratorOnClassMethod19(target=es2015).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod19.ts === | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
>decorator : Symbol(decorator, Decl(decoratorOnClassMethod19.ts, 1, 11)) | ||
|
||
class C1 { | ||
>C1 : Symbol(C1, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
|
||
#x | ||
>#x : Symbol(C1.#x, Decl(decoratorOnClassMethod19.ts, 3, 10)) | ||
|
||
@decorator((x: C1) => x.#x) | ||
>decorator : Symbol(decorator, Decl(decoratorOnClassMethod19.ts, 1, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
>C1 : Symbol(C1, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
>x.#x : Symbol(C1.#x, Decl(decoratorOnClassMethod19.ts, 3, 10)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
|
||
y() {} | ||
>y : Symbol(C1.y, Decl(decoratorOnClassMethod19.ts, 4, 6)) | ||
} | ||
|
||
class C2 { | ||
>C2 : Symbol(C2, Decl(decoratorOnClassMethod19.ts, 8, 1)) | ||
|
||
#x | ||
>#x : Symbol(C2.#x, Decl(decoratorOnClassMethod19.ts, 10, 10)) | ||
|
||
y(@decorator((x: C2) => x.#x) p) {} | ||
>y : Symbol(C2.y, Decl(decoratorOnClassMethod19.ts, 11, 6)) | ||
>decorator : Symbol(decorator, Decl(decoratorOnClassMethod19.ts, 1, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 13, 18)) | ||
>C2 : Symbol(C2, Decl(decoratorOnClassMethod19.ts, 8, 1)) | ||
>x.#x : Symbol(C2.#x, Decl(decoratorOnClassMethod19.ts, 10, 10)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 13, 18)) | ||
>p : Symbol(p, Decl(decoratorOnClassMethod19.ts, 13, 6)) | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/decoratorOnClassMethod19(target=es2015).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod19.ts === | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
>decorator : any | ||
|
||
class C1 { | ||
>C1 : C1 | ||
|
||
#x | ||
>#x : any | ||
|
||
@decorator((x: C1) => x.#x) | ||
>decorator((x: C1) => x.#x) : any | ||
>decorator : any | ||
>(x: C1) => x.#x : (x: C1) => any | ||
>x : C1 | ||
>x.#x : any | ||
>x : C1 | ||
|
||
y() {} | ||
>y : () => void | ||
} | ||
|
||
class C2 { | ||
>C2 : C2 | ||
|
||
#x | ||
>#x : any | ||
|
||
y(@decorator((x: C2) => x.#x) p) {} | ||
>y : (p: any) => void | ||
>decorator((x: C2) => x.#x) : any | ||
>decorator : any | ||
>(x: C2) => x.#x : (x: C2) => any | ||
>x : C2 | ||
>x.#x : any | ||
>x : C2 | ||
>p : any | ||
} | ||
|
55 changes: 55 additions & 0 deletions
55
tests/baselines/reference/decoratorOnClassMethod19(target=es2022).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//// [decoratorOnClassMethod19.ts] | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
|
||
class C1 { | ||
#x | ||
|
||
@decorator((x: C1) => x.#x) | ||
y() {} | ||
} | ||
|
||
class C2 { | ||
#x | ||
|
||
y(@decorator((x: C2) => x.#x) p) {} | ||
} | ||
|
||
|
||
//// [decoratorOnClassMethod19.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 __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
class C1 { | ||
#x; | ||
y() { } | ||
static { | ||
__decorate([ | ||
decorator((x) => x.#x), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], C1.prototype, "y", null); | ||
} | ||
} | ||
class C2 { | ||
#x; | ||
y(p) { } | ||
static { | ||
__decorate([ | ||
__param(0, decorator((x) => x.#x)), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Object]), | ||
__metadata("design:returntype", void 0) | ||
], C2.prototype, "y", null); | ||
} | ||
} |
Oops, something went wrong.