forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(46345): omit temp variable for computed property name in ambient …
…context (microsoft#46446)
- Loading branch information
1 parent
bedc8d4
commit 4b794fe
Showing
5 changed files
with
85 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//// [decoratorInAmbientContext.ts] | ||
declare function decorator(target: any, key: any): any; | ||
|
||
const b = Symbol('b'); | ||
class Foo { | ||
@decorator declare a: number; | ||
@decorator declare [b]: number; | ||
} | ||
|
||
|
||
//// [decoratorInAmbientContext.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; | ||
}; | ||
const b = Symbol('b'); | ||
class Foo { | ||
} | ||
__decorate([ | ||
decorator | ||
], Foo.prototype, "a", void 0); | ||
__decorate([ | ||
decorator | ||
], Foo.prototype, b, void 0); |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/decoratorInAmbientContext.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,23 @@ | ||
=== tests/cases/conformance/decorators/decoratorInAmbientContext.ts === | ||
declare function decorator(target: any, key: any): any; | ||
>decorator : Symbol(decorator, Decl(decoratorInAmbientContext.ts, 0, 0)) | ||
>target : Symbol(target, Decl(decoratorInAmbientContext.ts, 0, 27)) | ||
>key : Symbol(key, Decl(decoratorInAmbientContext.ts, 0, 39)) | ||
|
||
const b = Symbol('b'); | ||
>b : Symbol(b, Decl(decoratorInAmbientContext.ts, 2, 5)) | ||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --)) | ||
|
||
class Foo { | ||
>Foo : Symbol(Foo, Decl(decoratorInAmbientContext.ts, 2, 22)) | ||
|
||
@decorator declare a: number; | ||
>decorator : Symbol(decorator, Decl(decoratorInAmbientContext.ts, 0, 0)) | ||
>a : Symbol(Foo.a, Decl(decoratorInAmbientContext.ts, 3, 11)) | ||
|
||
@decorator declare [b]: number; | ||
>decorator : Symbol(decorator, Decl(decoratorInAmbientContext.ts, 0, 0)) | ||
>[b] : Symbol(Foo[b], Decl(decoratorInAmbientContext.ts, 4, 33)) | ||
>b : Symbol(b, Decl(decoratorInAmbientContext.ts, 2, 5)) | ||
} | ||
|
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,25 @@ | ||
=== tests/cases/conformance/decorators/decoratorInAmbientContext.ts === | ||
declare function decorator(target: any, key: any): any; | ||
>decorator : (target: any, key: any) => any | ||
>target : any | ||
>key : any | ||
|
||
const b = Symbol('b'); | ||
>b : unique symbol | ||
>Symbol('b') : unique symbol | ||
>Symbol : SymbolConstructor | ||
>'b' : "b" | ||
|
||
class Foo { | ||
>Foo : Foo | ||
|
||
@decorator declare a: number; | ||
>decorator : (target: any, key: any) => any | ||
>a : number | ||
|
||
@decorator declare [b]: number; | ||
>decorator : (target: any, key: any) => any | ||
>[b] : number | ||
>b : unique symbol | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
tests/cases/conformance/decorators/decoratorInAmbientContext.ts
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,10 @@ | ||
// @target: esnext | ||
// @experimentalDecorators: true | ||
|
||
declare function decorator(target: any, key: any): any; | ||
|
||
const b = Symbol('b'); | ||
class Foo { | ||
@decorator declare a: number; | ||
@decorator declare [b]: number; | ||
} |