-
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
- Loading branch information
Showing
13 changed files
with
337 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
43 changes: 43 additions & 0 deletions
43
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,43 @@ | ||
//// [decoratorOnClassMethod19.ts] | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
|
||
class Foo { | ||
#bar | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
baz() {} | ||
} | ||
|
||
|
||
//// [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 __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 _Foo_bar; | ||
class Foo { | ||
constructor() { | ||
_Foo_bar.set(this, void 0); | ||
} | ||
baz() { } | ||
} | ||
_Foo_bar = new WeakMap(); | ||
(() => { | ||
__decorate([ | ||
decorator((x) => __classPrivateFieldGet(x, _Foo_bar, "f")), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], Foo.prototype, "baz", null); | ||
})(); |
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
=== 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 Foo { | ||
>Foo : Symbol(Foo, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
|
||
#bar | ||
>#bar : Symbol(Foo.#bar, Decl(decoratorOnClassMethod19.ts, 3, 11)) | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
>decorator : Symbol(decorator, Decl(decoratorOnClassMethod19.ts, 1, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
>Foo : Symbol(Foo, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
>x.#bar : Symbol(Foo.#bar, Decl(decoratorOnClassMethod19.ts, 3, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
|
||
baz() {} | ||
>baz : Symbol(Foo.baz, Decl(decoratorOnClassMethod19.ts, 4, 8)) | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod19.ts === | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
>decorator : any | ||
|
||
class Foo { | ||
>Foo : Foo | ||
|
||
#bar | ||
>#bar : any | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
>decorator((x: Foo) => x.#bar) : any | ||
>decorator : any | ||
>(x: Foo) => x.#bar : (x: Foo) => any | ||
>x : Foo | ||
>x.#bar : any | ||
>x : Foo | ||
|
||
baz() {} | ||
>baz : () => void | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
//// [decoratorOnClassMethod19.ts] | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
|
||
class Foo { | ||
#bar | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
baz() {} | ||
} | ||
|
||
|
||
//// [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); | ||
}; | ||
class Foo { | ||
#bar; | ||
baz() { } | ||
static { | ||
__decorate([ | ||
decorator((x) => x.#bar), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], Foo.prototype, "baz", null); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/decoratorOnClassMethod19(target=es2022).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,22 @@ | ||
=== 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 Foo { | ||
>Foo : Symbol(Foo, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
|
||
#bar | ||
>#bar : Symbol(Foo.#bar, Decl(decoratorOnClassMethod19.ts, 3, 11)) | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
>decorator : Symbol(decorator, Decl(decoratorOnClassMethod19.ts, 1, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
>Foo : Symbol(Foo, Decl(decoratorOnClassMethod19.ts, 1, 27)) | ||
>x.#bar : Symbol(Foo.#bar, Decl(decoratorOnClassMethod19.ts, 3, 11)) | ||
>x : Symbol(x, Decl(decoratorOnClassMethod19.ts, 6, 16)) | ||
|
||
baz() {} | ||
>baz : Symbol(Foo.baz, Decl(decoratorOnClassMethod19.ts, 4, 8)) | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/decoratorOnClassMethod19(target=es2022).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,23 @@ | ||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod19.ts === | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
>decorator : any | ||
|
||
class Foo { | ||
>Foo : Foo | ||
|
||
#bar | ||
>#bar : any | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
>decorator((x: Foo) => x.#bar) : any | ||
>decorator : any | ||
>(x: Foo) => x.#bar : (x: Foo) => any | ||
>x : Foo | ||
>x.#bar : any | ||
>x : Foo | ||
|
||
baz() {} | ||
>baz : () => void | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/decoratorOnClassMethod19(target=esnext).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,34 @@ | ||
//// [decoratorOnClassMethod19.ts] | ||
// https://github.com/microsoft/TypeScript/issues/48515 | ||
declare var decorator: any; | ||
|
||
class Foo { | ||
#bar | ||
|
||
@decorator((x: Foo) => x.#bar) | ||
baz() {} | ||
} | ||
|
||
|
||
//// [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); | ||
}; | ||
class Foo { | ||
#bar; | ||
baz() { } | ||
static { | ||
__decorate([ | ||
decorator((x) => x.#bar), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", void 0) | ||
], Foo.prototype, "baz", null); | ||
} | ||
} |
Oops, something went wrong.