-
-
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.
fix(es/compat): Correctly handle
this
in arrow function parameters (#…
- Loading branch information
1 parent
46cfc5e
commit 52a8f05
Showing
9 changed files
with
115 additions
and
7 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,24 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": false | ||
}, | ||
"target": "es5", | ||
"transform": { | ||
"react": { | ||
"runtime": "automatic", | ||
"useBuiltins": true | ||
} | ||
}, | ||
"minify": { | ||
"compress": false, | ||
"mangle": false | ||
}, | ||
"loose": false | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": false | ||
} |
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,5 @@ | ||
class Foo { | ||
bar(v = this.a?.b?.c) {} | ||
} | ||
|
||
new Foo().bar(); |
22 changes: 22 additions & 0 deletions
22
crates/swc/tests/fixture/issues-8xxx/8488/1/output/index.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,22 @@ | ||
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; | ||
import { _ as _create_class } from "@swc/helpers/_/_create_class"; | ||
var Foo = function() { | ||
"use strict"; | ||
function Foo() { | ||
_class_call_check(this, Foo); | ||
} | ||
_create_class(Foo, [ | ||
{ | ||
key: "bar", | ||
value: function bar() { | ||
var _this = this; | ||
var v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { | ||
var _this_a_b, _this_a; | ||
return (_this_a = _this.a) === null || _this_a === void 0 ? void 0 : (_this_a_b = _this_a.b) === null || _this_a_b === void 0 ? void 0 : _this_a_b.c; | ||
}(); | ||
} | ||
} | ||
]); | ||
return Foo; | ||
}(); | ||
new Foo().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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript" | ||
}, | ||
"target": "es5" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
crates/swc/tests/fixture/issues-8xxx/8488/2/input/index.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,17 @@ | ||
function f1(x = this) {} | ||
function f2(x = () => this) {} | ||
function f3( | ||
x = () => { | ||
return this; | ||
}, | ||
) {} | ||
|
||
function bar() { | ||
function b1(x = this) {} | ||
function b2(x = () => this) {} | ||
function b3( | ||
x = () => { | ||
return this; | ||
}, | ||
) {} | ||
} |
32 changes: 32 additions & 0 deletions
32
crates/swc/tests/fixture/issues-8xxx/8488/2/output/index.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,32 @@ | ||
function f1() { | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; | ||
} | ||
function f2() { | ||
var _this = this; | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { | ||
return _this; | ||
}; | ||
} | ||
function f3() { | ||
var _this = this; | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { | ||
return _this; | ||
}; | ||
} | ||
function bar() { | ||
function b1() { | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this; | ||
} | ||
function b2() { | ||
var _this = this; | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { | ||
return _this; | ||
}; | ||
} | ||
function b3() { | ||
var _this = this; | ||
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function() { | ||
return _this; | ||
}; | ||
} | ||
} |
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