Skip to content

Commit 7f2a2c1

Browse files
authored
refactor(es/ast): Improve type definitions of patterns (#8532)
**Description:** - Copy `AssignmentTarget` from `oxc`. - Use `BindingIdentifier` in more places. **Related issue:** - Closes #8026
1 parent 47e7b89 commit 7f2a2c1

File tree

369 files changed

+7824
-6987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+7824
-6987
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let b;
2-
for(let i = 0; i < 2; ++i)b = 0 === i ? 1 : 2, console.log(0, b);
2+
for(let i = 0; i < 2; ++i)console.log(0, b = 0 === i ? 1 : 2);
33
let c = 1, d;
44
while(c--);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let b, c, d;
2-
for(let i = 0; i < 2; ++i)b = 0 === i ? 1 : 2, console.log(0, b);
2+
for(let i = 0; i < 2; ++i)console.log(0, b = 0 === i ? 1 : 2);
33
c = 1;
44
while(c--);
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export var fn = function() {
2-
var varA;
3-
return(// a bad comment
4-
varA = condCheck ? "a" : "b", objCreator({
5-
varA: varA
6-
}));
2+
return objCreator({
3+
varA: condCheck ? // a bad comment
4+
"a" : "b"
5+
});
76
};

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ var Point = /*#__PURE__*/ function() {
77
this.x = x;
88
this.y = y;
99
}
10-
Point.Origin // unexpected error here bug 840246
11-
= function Origin() {
10+
Point.Origin = function Origin() {
1211
return {
1312
x: 0,
1413
y: 0
1514
};
16-
};
15+
} // unexpected error here bug 840246
16+
;
1717
return Point;
1818
}();
1919
(function(Point) {
@@ -31,13 +31,13 @@ var A;
3131
this.x = x;
3232
this.y = y;
3333
}
34-
Point.Origin // unexpected error here bug 840246
35-
= function Origin() {
34+
Point.Origin = function Origin() {
3635
return {
3736
x: 0,
3837
y: 0
3938
};
40-
};
39+
} // unexpected error here bug 840246
40+
;
4141
return Point;
4242
}();
4343
A.Point = Point;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ var C = /*#__PURE__*/ function(B) {
4444
_proto.foo = function foo() {
4545
return 2;
4646
};
47-
_proto.qux // 2 errors, foo is abstract
48-
= function qux() {
47+
_proto.qux = function qux() {
4948
return _get(_get_prototype_of(C.prototype), "foo", this).call(this) || _get(_get_prototype_of(C.prototype), "foo", this);
50-
};
49+
} // 2 errors, foo is abstract
50+
;
5151
_proto.norf = function norf() {
5252
return _get(_get_prototype_of(C.prototype), "bar", this).call(this);
5353
};

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ var DerivedB = /*#__PURE__*/ function(BaseB1) {
7979
_proto.createInstance = function createInstance() {
8080
new DerivedB(7);
8181
};
82-
_proto.createBaseInstance // ok
83-
= function createBaseInstance() {
82+
_proto.createBaseInstance = function createBaseInstance() {
8483
new BaseB(8);
85-
};
86-
DerivedB.staticBaseInstance // ok
87-
= function staticBaseInstance() {
84+
} // ok
85+
;
86+
DerivedB.staticBaseInstance = function staticBaseInstance() {
8887
new BaseB(9);
89-
};
88+
} // ok
89+
;
9090
return DerivedB;
9191
}(BaseB);
9292
var DerivedC = /*#__PURE__*/ function(BaseC1) {
@@ -104,14 +104,14 @@ var DerivedC = /*#__PURE__*/ function(BaseC1) {
104104
_proto.createInstance = function createInstance() {
105105
new DerivedC(9);
106106
};
107-
_proto.createBaseInstance // error
108-
= function createBaseInstance() {
107+
_proto.createBaseInstance = function createBaseInstance() {
109108
new BaseC(10);
110-
};
111-
DerivedC.staticBaseInstance // error
112-
= function staticBaseInstance() {
109+
} // error
110+
;
111+
DerivedC.staticBaseInstance = function staticBaseInstance() {
113112
new BaseC(11);
114-
};
113+
} // error
114+
;
115115
return DerivedC;
116116
}(BaseC);
117117
var ba = new BaseA(1);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ var Derived = /*#__PURE__*/ function(Base1) {
1414
_class_call_check(this, Derived);
1515
return _super.apply(this, arguments);
1616
}
17-
Derived.make // ok
18-
= function make() {
17+
Derived.make = function make() {
1918
new Base();
20-
};
19+
} // ok
20+
;
2121
return Derived;
2222
}(Base);
2323
var Unrelated = /*#__PURE__*/ function() {
2424
"use strict";
2525
function Unrelated() {
2626
_class_call_check(this, Unrelated);
2727
}
28-
Unrelated.fake // error
29-
= function fake() {
28+
Unrelated.fake = function fake() {
3029
new Base();
31-
};
30+
} // error
31+
;
3232
return Unrelated;
3333
}();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//// [computedPropertyNames11_ES5.ts]
22
import { _ as _define_enumerable_properties } from "@swc/helpers/_/_define_enumerable_properties";
3-
var s, n, a, _mutatorMap = {};
4-
_mutatorMap[s] = _mutatorMap[s] || {}, _mutatorMap[s].get = function() {
3+
var s, n, a, _obj, _mutatorMap = {};
4+
_obj = {}, _mutatorMap[s] = _mutatorMap[s] || {}, _mutatorMap[s].get = function() {
55
return 0;
66
}, _mutatorMap[n] = _mutatorMap[n] || {}, _mutatorMap[n].set = function(v) {}, _mutatorMap[s + s] = _mutatorMap[s + s] || {}, _mutatorMap[s + s].get = function() {
77
return 0;
@@ -13,4 +13,4 @@ _mutatorMap[s] = _mutatorMap[s] || {}, _mutatorMap[s].get = function() {
1313
return 0;
1414
}, _mutatorMap["hello bye"] = _mutatorMap["hello bye"] || {}, _mutatorMap["hello bye"].set = function(v) {}, _mutatorMap["hello ".concat(a, " bye")] = _mutatorMap["hello ".concat(a, " bye")] || {}, _mutatorMap["hello ".concat(a, " bye")].get = function() {
1515
return 0;
16-
}, _define_enumerable_properties({}, _mutatorMap);
16+
}, _define_enumerable_properties(_obj, _mutatorMap);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//// [computedPropertyNames1_ES5.ts]
22
import { _ as _define_enumerable_properties } from "@swc/helpers/_/_define_enumerable_properties";
3-
var _mutatorMap = {};
4-
_mutatorMap[1] = _mutatorMap[1] || {}, _mutatorMap[1].get = function() {
3+
var _obj, _mutatorMap = {};
4+
_obj = {}, _mutatorMap[1] = _mutatorMap[1] || {}, _mutatorMap[1].get = function() {
55
return 0;
6-
}, _mutatorMap[1] = _mutatorMap[1] || {}, _mutatorMap[1].set = function(v) {}, _define_enumerable_properties({}, _mutatorMap);
6+
}, _mutatorMap[1] = _mutatorMap[1] || {}, _mutatorMap[1].set = function(v) {}, _define_enumerable_properties(_obj, _mutatorMap);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ var D = /*#__PURE__*/ function(C) {
2121
return _super.apply(this, arguments);
2222
}
2323
var _proto = D.prototype;
24-
_proto.foo // ok to drop parameters
25-
= function foo() {};
24+
_proto.foo = function foo() {} // ok to drop parameters
25+
;
2626
return D;
2727
}(C);
2828
var E = /*#__PURE__*/ function(D) {
@@ -34,8 +34,8 @@ var E = /*#__PURE__*/ function(D) {
3434
return _super.apply(this, arguments);
3535
}
3636
var _proto = E.prototype;
37-
_proto.foo // ok to add optional parameters
38-
= function foo(x) {};
37+
_proto.foo = function foo(x) {} // ok to add optional parameters
38+
;
3939
return E;
4040
}(D);
4141
var c;

0 commit comments

Comments
 (0)