Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add decorators version
2023-05
(#15570)
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
- Loading branch information
1 parent
f42e24d
commit 79fa181
Showing
350 changed files
with
8,678 additions
and
569 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,075 changes: 547 additions & 528 deletions
1,075
packages/babel-helpers/src/helpers/applyDecs2301.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
.../babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/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,8 @@ | ||
{ | ||
"plugins": [ | ||
["proposal-decorators", { "version": "2023-05" }], | ||
"proposal-class-properties", | ||
"proposal-private-methods", | ||
"proposal-class-static-block" | ||
] | ||
} |
56 changes: 56 additions & 0 deletions
56
...bel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/private/exec.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,56 @@ | ||
function dec({ get, set }, context) { | ||
context.addInitializer(function() { | ||
this[context.name + 'Context'] = context; | ||
}); | ||
|
||
return { | ||
get() { | ||
return get.call(this) + 1; | ||
}, | ||
|
||
set(v) { | ||
set.call(this, v + 1); | ||
}, | ||
|
||
init(v) { | ||
return v ? v : 1; | ||
} | ||
} | ||
} | ||
|
||
class Foo { | ||
@dec | ||
accessor #a; | ||
|
||
@dec | ||
accessor #b = 123; | ||
} | ||
|
||
let foo = new Foo(); | ||
|
||
const aContext = foo['#aContext']; | ||
const bContext = foo['#bContext']; | ||
|
||
expect(aContext.access.has(foo)).toBe(true); | ||
expect(aContext.access.has({})).toBe(false); | ||
expect(aContext.access.has(Object.create(foo))).toBe(false); | ||
|
||
expect(aContext.access.get(foo)).toBe(2); | ||
expect(() => aContext.access.get({})).toThrow(TypeError); | ||
aContext.access.set(foo, 123); | ||
expect(aContext.access.get(foo)).toBe(125); | ||
expect(() => aContext.access.set({}, 456)).toThrow(TypeError); | ||
expect(aContext.name).toBe('#a'); | ||
expect(aContext.kind).toBe('accessor'); | ||
expect(aContext.static).toBe(false); | ||
expect(aContext.private).toBe(true); | ||
expect(typeof aContext.addInitializer).toBe('function'); | ||
|
||
expect(bContext.access.get(foo)).toBe(124); | ||
bContext.access.set(foo, 123); | ||
expect(bContext.access.get(foo)).toBe(125); | ||
expect(bContext.name).toBe('#b'); | ||
expect(bContext.kind).toBe('accessor'); | ||
expect(bContext.static).toBe(false); | ||
expect(bContext.private).toBe(true); | ||
expect(typeof bContext.addInitializer).toBe('function'); |
Oops, something went wrong.