-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(es/typescript): Simplifying enum and namespace transforms (#…
- Loading branch information
1 parent
ec0a62c
commit 2480bb0
Showing
690 changed files
with
3,049 additions
and
3,337 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
swc_ecma_transforms_typescript: patch | ||
swc_ecma_utils: breaking | ||
swc_core: patch | ||
swc_ecma_transforms: patch | ||
--- | ||
|
||
refactor(es/typescript): Simplifying enum and namespace transforms |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from "react"; | ||
export var Test; | ||
(function(Test) { | ||
Test.content = /*#__PURE__*/ React.createElement("div", null, "Content"); | ||
})(Test || (Test = {})); | ||
export var Test; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
var A; | ||
(function(A) { | ||
A.Foo = function() { | ||
return /*#__PURE__*/ React.createElement("div", null); | ||
}; | ||
})(A || (A = {})); | ||
var A; |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
var A; | ||
(function(A) { | ||
A.v = 25; | ||
function a() { | ||
console.log(A.v); | ||
} | ||
A.a = a; | ||
})(A || (A = {})); | ||
var A; |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export var RuleInterpreterHelper; | ||
(function(RuleInterpreterHelper) { | ||
RuleInterpreterHelper.fieldNameMap = []; | ||
RuleInterpreterHelper.fieldNameHashMap = new Map(RuleInterpreterHelper.fieldNameMap); | ||
})(RuleInterpreterHelper || (RuleInterpreterHelper = {})); | ||
export var RuleInterpreterHelper; |
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
export var Test; | ||
(function(t) { | ||
let e; | ||
(function(t) { | ||
t["Test"] = "1"; | ||
t["Test2"] = "2"; | ||
t["Test3"] = "3"; | ||
})(e = t.testEnum || (t.testEnum = {})); | ||
let s; | ||
})(t.testEnum || (t.testEnum = {})); | ||
(function(t) { | ||
t["Test"] = "1"; | ||
t["Test2"] = "2"; | ||
t["Test3"] = "3"; | ||
})(s = t.testEnum2 || (t.testEnum2 = {})); | ||
})(t.testEnum2 || (t.testEnum2 = {})); | ||
})(Test || (Test = {})); | ||
export var Test; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var n; | ||
(function(n) { | ||
var ref; | ||
ref = { | ||
a: 1 | ||
}, n.a = ref.a, ref; | ||
})(n || (n = {})); | ||
var n; |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
var Foo; | ||
(function(Foo) { | ||
var ref; | ||
ref = { | ||
a: 1, | ||
b: 2 | ||
}, Foo.A = ref.a, Foo.B = ref.b, ref; | ||
})(Foo || (Foo = {})); | ||
var Foo; |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var foo; | ||
(function(foo) { | ||
foo.bar = 0; | ||
})(foo || (foo = {})); | ||
export { foo }; | ||
var foo; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
var o; | ||
import { test as r } from "test"; | ||
(o || (o = {})).Hello = "World!", r("World!"); | ||
import { test as o } from "test"; | ||
var r, l = ((r = l || {}).Hello = "World!", r); | ||
o("World!"); |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export var Test; | ||
(function(Test) { | ||
export var Test = /*#__PURE__*/ function(Test) { | ||
Test[Test["A"] = 1073741824] = "A"; | ||
Test[Test["B"] = -2147483648] = "B"; | ||
Test[Test["C"] = -1073741824] = "C"; | ||
})(Test || (Test = {})); | ||
return Test; | ||
}({}); | ||
var a = 1 << 30; // 1073741824 | ||
var b = 1 << 31; // -2147483648 | ||
var c = 1 << 30 | 1 << 31; // -1073741824 |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
var Foo; | ||
(function(Foo) { | ||
var Foo = /*#__PURE__*/ function(Foo) { | ||
Foo[Foo["a"] = 0] = "a"; | ||
Foo[Foo["b"] = 1] = "b"; | ||
Foo[Foo["c"] = 0] = "c"; | ||
Foo[Foo["d"] = 0] = "d"; | ||
Foo[Foo["e"] = 1] = "e"; | ||
Foo[Foo["f"] = 2] = "f"; | ||
})(Foo || (Foo = {})); | ||
return Foo; | ||
}(Foo || {}); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var Bar; | ||
(function(Bar) { | ||
var Bar = /*#__PURE__*/ function(Bar) { | ||
Bar[Bar["VALUE"] = 1] = "VALUE"; | ||
})(Bar || (Bar = {})); | ||
return Bar; | ||
}(Bar || {}); | ||
export default Bar; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import * as React from 'react'; | ||
export var FooNs; | ||
(function(FooNs) { | ||
FooNs.Shared = ()=>'I\'m shared component'; | ||
FooNs.Main = ()=>/*#__PURE__*/ React.createElement(FooNs.Shared, null); | ||
})(FooNs || (FooNs = {})); | ||
export var FooNs; |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import * as React from 'react'; | ||
export var Ns; | ||
(function(Ns) { | ||
Ns.Context = /*#__PURE__*/ React.createContext(); | ||
Ns.Component = ()=>/*#__PURE__*/ React.createElement(Ns.Context.Provider, null); | ||
})(Ns || (Ns = {})); | ||
export var Ns; |
43 changes: 19 additions & 24 deletions
43
crates/swc/tests/fixture/issues-9xxx/9531/output/index.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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
if (true) { | ||
var A; | ||
(function(A) {})(A || (A = {})); | ||
} | ||
do { | ||
var B; | ||
(function(B) {})(B || (B = {})); | ||
}while (false) | ||
while(false){ | ||
var C; | ||
(function(C) {})(C || (C = {})); | ||
} | ||
if (true) var A = /*#__PURE__*/ function(A) { | ||
return A; | ||
}(A || {}); | ||
do var B = /*#__PURE__*/ function(B) { | ||
return B; | ||
}(B || {}); | ||
while (false) | ||
while(false)var C = /*#__PURE__*/ function(C) { | ||
return C; | ||
}(C || {}); | ||
; | ||
for(; false;){ | ||
var D; | ||
(function(D) {})(D || (D = {})); | ||
} | ||
for(; false;)var D = /*#__PURE__*/ function(D) { | ||
return D; | ||
}(D || {}); | ||
; | ||
for(const a in {}){ | ||
var E; | ||
(function(E) {})(E || (E = {})); | ||
} | ||
for(const a in {})var E = /*#__PURE__*/ function(E) { | ||
return E; | ||
}(E || {}); | ||
; | ||
for (const a of []){ | ||
var F; | ||
(function(F) {})(F || (F = {})); | ||
} | ||
for (const a of [])var F = /*#__PURE__*/ function(F) { | ||
return F; | ||
}(F || {}); | ||
; |
14 changes: 7 additions & 7 deletions
14
crates/swc/tests/fixture/ts-inline-enum/default/output/index.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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
var Foo; | ||
(function(Foo) { | ||
var Foo = /*#__PURE__*/ function(Foo) { | ||
Foo[Foo["hello"] = 42] = "hello"; | ||
})(Foo || (Foo = {})); | ||
var Foo2; | ||
(function(Foo2) { | ||
return Foo; | ||
}(Foo || {}); | ||
var Foo2 = /*#__PURE__*/ function(Foo2) { | ||
Foo2["hello"] = "42"; | ||
})(Foo2 || (Foo2 = {})); | ||
return Foo2; | ||
}(Foo2 || {}); | ||
console.log(42, "42"); | ||
console.log("hello", "こんにちは", "안녕하세요", "你好"); | ||
var Hello; | ||
; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
var Foo; | ||
; | ||
var x; | ||
var ref; | ||
ref = void 0, x = ref === void 0 ? 42 : ref; | ||
|
16 changes: 8 additions & 8 deletions
16
crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum-2/output/index.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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
var Foo; | ||
(function(Foo) { | ||
var Foo = /*#__PURE__*/ function(Foo) { | ||
Foo[Foo["hello"] = 42] = "hello"; | ||
})(Foo || (Foo = {})); | ||
var Foo2; | ||
(function(Foo2) { | ||
return Foo; | ||
}(Foo || {}); | ||
var Foo2 = /*#__PURE__*/ function(Foo2) { | ||
Foo2["hello"] = "42"; | ||
})(Foo2 || (Foo2 = {})); | ||
var Bar; | ||
var Bar2; | ||
return Foo2; | ||
}(Foo2 || {}); | ||
; | ||
; | ||
console.log(42, "42"); | ||
console.log(42, "42"); |
16 changes: 8 additions & 8 deletions
16
crates/swc/tests/fixture/ts-inline-enum/treatConstEnumAsEnum/output/index.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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
var Foo; | ||
(function(Foo) { | ||
var Foo = /*#__PURE__*/ function(Foo) { | ||
Foo[Foo["hello"] = 42] = "hello"; | ||
})(Foo || (Foo = {})); | ||
var Foo2; | ||
(function(Foo2) { | ||
return Foo; | ||
}(Foo || {}); | ||
var Foo2 = /*#__PURE__*/ function(Foo2) { | ||
Foo2["hello"] = "42"; | ||
})(Foo2 || (Foo2 = {})); | ||
var Bar; | ||
var Bar2; | ||
return Foo2; | ||
}(Foo2 || {}); | ||
; | ||
; | ||
console.log(42, "42"); | ||
console.log(42, "42"); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export var Foo; | ||
(function(Foo) { | ||
export var Foo = /*#__PURE__*/ function(Foo) { | ||
Foo["A"] = "foo"; | ||
Foo["B"] = "bar"; | ||
})(Foo || (Foo = {})); | ||
return Foo; | ||
}({}); |
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
Oops, something went wrong.