-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/decorators): Do not insert duplicate constructors (#8631)
**Description:** Doesn't insert a duplicate ctor when the ctor uses overloads in TS. **Related issue:** - Closes #8630.
- Loading branch information
Showing
6 changed files
with
92 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
13 changes: 13 additions & 0 deletions
13
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/input.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,13 @@ | ||
const decorate = (target: unknown, context: DecoratorContext) => { | ||
console.log("decorated"); | ||
}; | ||
|
||
export class Color { | ||
constructor(hex: string); | ||
constructor(r: number, g: number, b: number, a?: number); | ||
constructor(r: string | number, g?: number, b?: number, a = 1) {} | ||
|
||
@decorate get rgba() { | ||
return [0, 0, 0, 1]; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/output.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,2 @@ | ||
export default class T { | ||
} |
28 changes: 28 additions & 0 deletions
28
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/1/output.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,28 @@ | ||
var _initProto; | ||
const decorate = (target: unknown, context: DecoratorContext)=>{ | ||
console.log("decorated"); | ||
}; | ||
export class Color { | ||
static{ | ||
({ e: [_initProto] } = _apply_decs_2203_r(this, [ | ||
[ | ||
decorate, | ||
3, | ||
"rgba" | ||
] | ||
], [])); | ||
} | ||
constructor(hex: string); | ||
constructor(r: number, g: number, b: number, a?: number); | ||
constructor(r: string | number, g?: number, b?: number, a = 1){ | ||
_initProto(this); | ||
} | ||
get rgba() { | ||
return [ | ||
0, | ||
0, | ||
0, | ||
1 | ||
]; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_proposal/tests/decorators/issue-8631/options.json
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,3 @@ | ||
{ | ||
"plugins": [["proposal-decorators", { "version": "2022-03" }]] | ||
} |