Skip to content

Commit 21951b3

Browse files
committed
refactor(es/ast)!: use Function for object accessors
1 parent f3eddaa commit 21951b3

136 files changed

Lines changed: 4633 additions & 3648 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
swc_core: major
3+
swc_ecma_ast: major
4+
swc_ecma_codegen: major
5+
swc_ecma_compat_common: major
6+
swc_ecma_compat_es2015: major
7+
swc_ecma_compat_es2022: major
8+
swc_ecma_lexer: major
9+
swc_ecma_lints: major
10+
swc_ecma_minifier: major
11+
swc_ecma_parser: major
12+
swc_ecma_quote_macros: major
13+
swc_ecma_react_compiler: major
14+
swc_ecma_transformer: major
15+
swc_ecma_transforms_base: major
16+
swc_ecma_transforms_classes: major
17+
swc_ecma_transforms_module: major
18+
swc_ecma_transforms_optimization: major
19+
swc_ecma_transforms_proposal: major
20+
swc_ecma_transforms_typescript: major
21+
swc_ecma_utils: major
22+
swc_ecma_visit: major
23+
swc_estree_compat: major
24+
swc_ts_fast_strip: major
25+
swc_typescript: major
26+
---
27+
28+
refactor(es/ast)!: Use `Function` for object accessors

bindings/binding_core_wasm/src/types.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,18 +2297,13 @@ export interface AssignmentProperty extends Node {
22972297
export interface GetterProperty extends PropBase, HasSpan {
22982298
type: "GetterProperty";
22992299
2300-
typeAnnotation?: TsTypeAnnotation;
2301-
2302-
body?: BlockStatement;
2300+
function: Fn;
23032301
}
23042302
23052303
export interface SetterProperty extends PropBase, HasSpan {
23062304
type: "SetterProperty";
23072305
2308-
thisParam?: Pattern;
2309-
2310-
param: Pattern;
2311-
body?: BlockStatement;
2306+
function: Fn;
23122307
}
23132308
23142309
export interface MethodProperty extends PropBase, Fn {

bindings/binding_minifier_wasm/src/types.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,18 +2194,13 @@ export interface AssignmentProperty extends Node {
21942194
export interface GetterProperty extends PropBase, HasSpan {
21952195
type: "GetterProperty";
21962196
2197-
typeAnnotation?: TsTypeAnnotation;
2198-
2199-
body?: BlockStatement;
2197+
function: Fn;
22002198
}
22012199
22022200
export interface SetterProperty extends PropBase, HasSpan {
22032201
type: "SetterProperty";
22042202
2205-
thisParam?: Pattern;
2206-
2207-
param: Pattern;
2208-
body?: BlockStatement;
2203+
function: Fn;
22092204
}
22102205
22112206
export interface MethodProperty extends PropBase, Fn {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
System.register([],function(e,t){"use strict";var r,s;var a={set a(_value){s=_value;e("a",s)}};e("a",void 0);return{setters:[],execute:function(){r=1;({a:a.a}=source)}}});
1+
System.register([],function(e,t){"use strict";var r,s;var a={set a(t){s=t;e("a",s)}};e("a",void 0);return{setters:[],execute:function(){r=1;({a:a.a}=source)}}});

crates/swc/tests/fixture/issues-8xxx/8148/output/input.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ function _toBeMocked() {
22
return "I am the original function";
33
}
44
export var toBeMocked = _toBeMocked;
5-
var _$mock = {
5+
export var mock = {
66
get toBeMocked () {
77
return toBeMocked;
88
},
99
set toBeMocked (mock){
1010
toBeMocked = mock;
1111
}
1212
};
13-
export { _$mock as mock };

crates/swc/tests/tsc-references/accessorWithES5.1.normal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var D = /*#__PURE__*/ function() {
2424
_create_class(D, [
2525
{
2626
key: "x",
27-
set: function set(v1) {}
27+
set: function set(v) {}
2828
}
2929
]);
3030
return D;

crates/swc/tests/tsc-references/computedPropertyNames11_ES6.1.normal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
var s;
33
var n;
44
var a;
5-
var v1 = {
5+
var v = {
66
get [s] () {
77
return 0;
88
},

crates/swc/tests/tsc-references/computedPropertyNames1_ES6.1.normal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//// [computedPropertyNames1_ES6.ts]
2-
var v1 = {
2+
var v = {
33
get [0 + 1] () {
44
return 0;
55
},

crates/swc/tests/tsc-references/jsDeclarationsFunctionLikeClasses2.1.normal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ Vec.prototype = {
3131
/**
3232
* @param {number} x
3333
* @param {number} y
34-
*/ export function Point2D(x1, y1) {
34+
*/ export function Point2D(x, y) {
3535
if (!_instanceof(this, Point2D)) {
36-
return new Point2D(x1, y1);
36+
return new Point2D(x, y);
3737
}
3838
Vec.call(this, 2);
39-
this.x = x1;
40-
this.y = y1;
39+
this.x = x;
40+
this.y = y;
4141
}
4242
Point2D.prototype = {
4343
__proto__: Vec,

crates/swc/tests/tsc-references/jsDeclarationsFunctionLikeClasses2.2.minified.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Vec.prototype = {
1414
return Math.sqrt(sum);
1515
}
1616
};
17-
export function Point2D(x1, y1) {
18-
if (!_instanceof(this, Point2D)) return new Point2D(x1, y1);
19-
Vec.call(this, 2), this.x = x1, this.y = y1;
17+
export function Point2D(x, y) {
18+
if (!_instanceof(this, Point2D)) return new Point2D(x, y);
19+
Vec.call(this, 2), this.x = x, this.y = y;
2020
}
2121
Point2D.prototype = {
2222
__proto__: Vec,

0 commit comments

Comments
 (0)