-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
671 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...n-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/assignment/output.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,8 @@ | ||
"use strict"; | ||
var _obj$a, _obj$b, _obj$a2; | ||
const obj = { a: { b: { c: { d: 2 } } } }; | ||
const a = obj === null || obj === void 0 ? void 0 : obj.a; | ||
const b = obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b; | ||
const bad = obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b; | ||
let val; | ||
val = obj === null || obj === void 0 || (_obj$a2 = obj.a) === null || _obj$a2 === void 0 ? void 0 : _obj$a2.b; |
85 changes: 85 additions & 0 deletions
85
...nsform-optional-chaining/test/fixtures/assumption-noDocumentAll/cast-to-boolean/output.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,85 @@ | ||
class C { | ||
static testIf(o) { | ||
if (o !== null && o !== void 0 && o.a.b.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testConditional(o) { | ||
var _o$a$b; | ||
return o !== null && o !== void 0 && (_o$a$b = o.a.b) !== null && _o$a$b !== void 0 && _o$a$b.c.d ? true : false; | ||
} | ||
static testLoop(o) { | ||
while (o !== null && o !== void 0 && o.a.b.c.d) { | ||
var _o$a$b$c; | ||
for (; o !== null && o !== void 0 && (_o$a$b$c = o.a.b.c) !== null && _o$a$b$c !== void 0 && _o$a$b$c.d;) { | ||
var _o$a$b2; | ||
let i = 0; | ||
do { | ||
i++; | ||
if (i === 2) { | ||
return true; | ||
} | ||
} while (o !== null && o !== void 0 && (_o$a$b2 = o.a.b) !== null && _o$a$b2 !== void 0 && _o$a$b2.c.d); | ||
} | ||
} | ||
return false; | ||
} | ||
static testNegate(o) { | ||
var _o$a$b3; | ||
return !!(o !== null && o !== void 0 && (_o$a$b3 = o.a.b) !== null && _o$a$b3 !== void 0 && _o$a$b3.c.d); | ||
} | ||
static testIfDeep(o) { | ||
var _o$obj; | ||
if ((_o$obj = o.obj) !== null && _o$obj !== void 0 && (_o$obj = _o$obj.a.b) !== null && _o$obj !== void 0 && _o$obj.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testConditionalDeep(o) { | ||
var _o$obj2; | ||
return (_o$obj2 = o.obj) !== null && _o$obj2 !== void 0 && (_o$obj2 = _o$obj2.a.b) !== null && _o$obj2 !== void 0 && _o$obj2.c.d ? true : false; | ||
} | ||
static testLoopDeep(o) { | ||
var _o$obj3; | ||
while ((_o$obj3 = o.obj) !== null && _o$obj3 !== void 0 && _o$obj3.a.b.c.d) { | ||
var _o$obj4; | ||
for (; (_o$obj4 = o.obj) !== null && _o$obj4 !== void 0 && (_o$obj4 = _o$obj4.a.b.c) !== null && _o$obj4 !== void 0 && _o$obj4.d;) { | ||
var _o$obj5; | ||
let i = 0; | ||
do { | ||
i++; | ||
if (i === 2) { | ||
return true; | ||
} | ||
} while ((_o$obj5 = o.obj) !== null && _o$obj5 !== void 0 && (_o$obj5 = _o$obj5.a.b) !== null && _o$obj5 !== void 0 && _o$obj5.c.d); | ||
} | ||
} | ||
return false; | ||
} | ||
static testNegateDeep(o) { | ||
var _o$obj6; | ||
return !!((_o$obj6 = o.obj) !== null && _o$obj6 !== void 0 && (_o$obj6 = _o$obj6.a.b) !== null && _o$obj6 !== void 0 && _o$obj6.c.d); | ||
} | ||
static testLogicalInIf(o) { | ||
var _o$a$b4, _o$a; | ||
if (o !== null && o !== void 0 && (_o$a$b4 = o.a.b) !== null && _o$a$b4 !== void 0 && _o$a$b4.c.d && o !== null && o !== void 0 && (_o$a = o.a) !== null && _o$a !== void 0 && _o$a.b.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testLogicalInReturn(o) { | ||
var _o$a$b5, _o$a2; | ||
return (o === null || o === void 0 || (_o$a$b5 = o.a.b) === null || _o$a$b5 === void 0 ? void 0 : _o$a$b5.c.d) && (o === null || o === void 0 || (_o$a2 = o.a) === null || _o$a2 === void 0 ? void 0 : _o$a2.b.c.d); | ||
} | ||
static testNullishCoalescing(o) { | ||
var _o$a$b$c$non_existent, _o$a$b6, _o$a$b7, _o$a$b$c$non_existent3, _o$a$b10; | ||
if ((_o$a$b$c$non_existent = o === null || o === void 0 || (_o$a$b6 = o.a.b) === null || _o$a$b6 === void 0 ? void 0 : _o$a$b6.c.non_existent) !== null && _o$a$b$c$non_existent !== void 0 ? _o$a$b$c$non_existent : o === null || o === void 0 || (_o$a$b7 = o.a.b) === null || _o$a$b7 === void 0 ? void 0 : _o$a$b7.c.d) { | ||
var _o$a$b$c$non_existent2, _o$a$b8, _o$a$b9; | ||
return (_o$a$b$c$non_existent2 = o === null || o === void 0 || (_o$a$b8 = o.a.b) === null || _o$a$b8 === void 0 ? void 0 : _o$a$b8.c.non_existent) !== null && _o$a$b$c$non_existent2 !== void 0 ? _o$a$b$c$non_existent2 : o === null || o === void 0 || (_o$a$b9 = o.a.b) === null || _o$a$b9 === void 0 ? void 0 : _o$a$b9.c.d; | ||
} | ||
return (_o$a$b$c$non_existent3 = o === null || o === void 0 || (_o$a$b10 = o.a.b) === null || _o$a$b10 === void 0 ? void 0 : _o$a$b10.c.non_existent) !== null && _o$a$b$c$non_existent3 !== void 0 ? _o$a$b$c$non_existent3 : o; | ||
} | ||
} | ||
C.test(); | ||
C.testNullish(); |
19 changes: 19 additions & 0 deletions
19
...orm-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.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,19 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) === null || _x === void 0 ? void 0 : _x.y; | ||
})()) {} | ||
function g({ a, b = (() => { | ||
return a === null || a === void 0 ? void 0 : a.c; | ||
})() }) {} | ||
function h(a, { b = (() => { | ||
var _a$b; | ||
return (_a$b = a.b) === null || _a$b === void 0 || (_a$b = _a$b.c) === null || _a$b === void 0 ? void 0 : _a$b.d.e; | ||
})() }) {} | ||
function i(a, { b = (() => { | ||
var _a$b2; | ||
return (_a$b2 = a.b) === null || _a$b2 === void 0 || (_a$b2 = _a$b2.c) === null || _a$b2 === void 0 ? void 0 : _a$b2.d; | ||
})().e }) {} | ||
function j(a, { b = (() => { | ||
var _a$b3; | ||
return a === null || a === void 0 || (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e; | ||
})() }) {} |
18 changes: 18 additions & 0 deletions
18
...ugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/memoize/output.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,18 @@ | ||
function test(foo) { | ||
var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar$baz2, _foo$bar4, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar8$baz, _foo$bar9, _foo$bar9$baz; | ||
foo === null || foo === void 0 || foo.bar; | ||
foo === null || foo === void 0 || (_foo$bar = foo.bar) === null || _foo$bar === void 0 || _foo$bar.baz; | ||
foo === null || foo === void 0 || foo(foo); | ||
foo === null || foo === void 0 || foo.bar(); | ||
(_foo$get = foo.get(bar)) === null || _foo$get === void 0 || _foo$get(); | ||
(_foo$bar2 = foo.bar()) === null || _foo$bar2 === void 0 || _foo$bar2(); | ||
(_foo$bar3 = foo[bar]()) === null || _foo$bar3 === void 0 || _foo$bar3(); | ||
(_foo$bar$baz = foo.bar().baz) === null || _foo$bar$baz === void 0 || _foo$bar$baz(); | ||
(_foo$bar$baz2 = foo[bar]().baz) === null || _foo$bar$baz2 === void 0 || _foo$bar$baz2(); | ||
(_foo$bar4 = foo.bar) === null || _foo$bar4 === void 0 || _foo$bar4.call(foo, foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar5 = foo.bar) === null || _foo$bar5 === void 0 || _foo$bar5.call(foo, foo.bar, true); | ||
(_foo$bar6 = foo.bar) === null || _foo$bar6 === void 0 || _foo$bar6.baz(foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 || _foo$bar7.baz(foo.bar, true); | ||
(_foo$bar8 = foo.bar) === null || _foo$bar8 === void 0 || (_foo$bar8$baz = _foo$bar8.baz) === null || _foo$bar8$baz === void 0 || _foo$bar8$baz.call(_foo$bar8, foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar9 = foo.bar) === null || _foo$bar9 === void 0 || (_foo$bar9$baz = _foo$bar9.baz) === null || _foo$bar9$baz === void 0 || _foo$bar9$baz.call(_foo$bar9, foo.bar, true); | ||
} |
10 changes: 10 additions & 0 deletions
10
...orm-optional-chaining/test/fixtures/assumption-noDocumentAll/optional-eval-call/output.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,10 @@ | ||
var _eval, _eval2, _foo$eval, _eval$foo; | ||
var foo; | ||
eval === null || eval === void 0 || (0, eval)(foo); | ||
eval === null || eval === void 0 || (0, eval)(foo); | ||
eval === null || eval === void 0 || (0, eval)()(); | ||
eval === null || eval === void 0 || (0, eval)().foo; | ||
(_eval = eval()) === null || _eval === void 0 || _eval(); | ||
(_eval2 = eval()) === null || _eval2 === void 0 || _eval2.foo; | ||
(_foo$eval = foo.eval) === null || _foo$eval === void 0 || _foo$eval.call(foo, foo); | ||
(_eval$foo = eval.foo) === null || _eval$foo === void 0 || _eval$foo.call(eval, foo); |
12 changes: 12 additions & 0 deletions
12
...form-optional-chaining/test/fixtures/assumption-noDocumentAll/super-method-call/output.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,12 @@ | ||
"use strict"; | ||
class Base { | ||
method() { | ||
return "Hello!"; | ||
} | ||
} | ||
class Derived extends Base { | ||
method() { | ||
var _super$method; | ||
return (_super$method = super.method) === null || _super$method === void 0 ? void 0 : _super$method.call(this); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...-transform-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.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,11 @@ | ||
var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo$bar2, _foo7, _foo$bar3, _foo8, _foo9, _foo9$bar, _foo10, _foo10$bar; | ||
(_foo = foo) === null || _foo === void 0 || _foo(foo); | ||
(_foo2 = foo) === null || _foo2 === void 0 || _foo2.bar(); | ||
(_foo$bar = (_foo3 = foo).bar) === null || _foo$bar === void 0 || _foo$bar.call(_foo3, foo.bar, false); | ||
(_foo4 = foo) === null || _foo4 === void 0 || (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 || _foo4$bar.call(_foo4, foo.bar, true); | ||
(_foo5 = foo) === null || _foo5 === void 0 || _foo5().bar; | ||
(_foo6 = foo) === null || _foo6 === void 0 || (_foo6 = _foo6()) === null || _foo6 === void 0 || _foo6.bar; | ||
(_foo$bar2 = (_foo7 = foo).bar) === null || _foo$bar2 === void 0 || _foo$bar2.call(_foo7).baz; | ||
(_foo$bar3 = (_foo8 = foo).bar) === null || _foo$bar3 === void 0 || (_foo$bar3 = _foo$bar3.call(_foo8)) === null || _foo$bar3 === void 0 || _foo$bar3.baz; | ||
(_foo9 = foo) === null || _foo9 === void 0 || (_foo9$bar = _foo9.bar) === null || _foo9$bar === void 0 || _foo9$bar.call(_foo9).baz; | ||
(_foo10 = foo) === null || _foo10 === void 0 || (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 || (_foo10$bar = _foo10$bar.call(_foo10)) === null || _foo10$bar === void 0 || _foo10$bar.baz; |
18 changes: 18 additions & 0 deletions
18
...plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/memoize/output.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,18 @@ | ||
function test(foo) { | ||
var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar$baz2, _foo$bar4, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar8$baz, _foo$bar9, _foo$bar9$baz; | ||
foo === null || foo === void 0 || foo.bar; | ||
foo === null || foo === void 0 || (_foo$bar = foo.bar) === null || _foo$bar === void 0 || _foo$bar.baz; | ||
foo === null || foo === void 0 || foo(foo); | ||
foo === null || foo === void 0 || foo.bar(); | ||
(_foo$get = foo.get(bar)) === null || _foo$get === void 0 || _foo$get(); | ||
(_foo$bar2 = foo.bar()) === null || _foo$bar2 === void 0 || _foo$bar2(); | ||
(_foo$bar3 = foo[bar]()) === null || _foo$bar3 === void 0 || _foo$bar3(); | ||
(_foo$bar$baz = foo.bar().baz) === null || _foo$bar$baz === void 0 || _foo$bar$baz(); | ||
(_foo$bar$baz2 = foo[bar]().baz) === null || _foo$bar$baz2 === void 0 || _foo$bar$baz2(); | ||
(_foo$bar4 = foo.bar) === null || _foo$bar4 === void 0 || _foo$bar4.call(foo, foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar5 = foo.bar) === null || _foo$bar5 === void 0 || _foo$bar5.call(foo, foo.bar, true); | ||
(_foo$bar6 = foo.bar) === null || _foo$bar6 === void 0 || _foo$bar6.baz(foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 || _foo$bar7.baz(foo.bar, true); | ||
(_foo$bar8 = foo.bar) === null || _foo$bar8 === void 0 || (_foo$bar8$baz = _foo$bar8.baz) === null || _foo$bar8$baz === void 0 || _foo$bar8$baz.call(_foo$bar8, foo.bar, false); | ||
foo === null || foo === void 0 || (_foo$bar9 = foo.bar) === null || _foo$bar9 === void 0 || (_foo$bar9$baz = _foo$bar9.baz) === null || _foo$bar9$baz === void 0 || _foo$bar9$baz.call(_foo$bar9, foo.bar, true); | ||
} |
12 changes: 12 additions & 0 deletions
12
...nsform-optional-chaining/test/fixtures/assumption-pureGetters/super-method-call/output.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,12 @@ | ||
"use strict"; | ||
class Base { | ||
method() { | ||
return "Hello!"; | ||
} | ||
} | ||
class Derived extends Base { | ||
method() { | ||
var _super$method; | ||
return (_super$method = super.method) === null || _super$method === void 0 ? void 0 : _super$method.call(this); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...shots/babel-plugin-transform-optional-chaining/test/fixtures/general/assignment/output.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,8 @@ | ||
"use strict"; | ||
var _obj$a, _obj$b, _obj$a2; | ||
const obj = { a: { b: { c: { d: 2 } } } }; | ||
const a = obj === null || obj === void 0 ? void 0 : obj.a; | ||
const b = obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b; | ||
const bad = obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b; | ||
let val; | ||
val = obj === null || obj === void 0 || (_obj$a2 = obj.a) === null || _obj$a2 === void 0 ? void 0 : _obj$a2.b; |
85 changes: 85 additions & 0 deletions
85
.../babel-plugin-transform-optional-chaining/test/fixtures/general/cast-to-boolean/output.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,85 @@ | ||
class C { | ||
static testIf(o) { | ||
if (o !== null && o !== void 0 && o.a.b.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testConditional(o) { | ||
var _o$a$b; | ||
return o !== null && o !== void 0 && (_o$a$b = o.a.b) !== null && _o$a$b !== void 0 && _o$a$b.c.d ? true : false; | ||
} | ||
static testLoop(o) { | ||
while (o !== null && o !== void 0 && o.a.b.c.d) { | ||
var _o$a$b$c; | ||
for (; o !== null && o !== void 0 && (_o$a$b$c = o.a.b.c) !== null && _o$a$b$c !== void 0 && _o$a$b$c.d;) { | ||
var _o$a$b2; | ||
let i = 0; | ||
do { | ||
i++; | ||
if (i === 2) { | ||
return true; | ||
} | ||
} while (o !== null && o !== void 0 && (_o$a$b2 = o.a.b) !== null && _o$a$b2 !== void 0 && _o$a$b2.c.d); | ||
} | ||
} | ||
return false; | ||
} | ||
static testNegate(o) { | ||
var _o$a$b3; | ||
return !!(o !== null && o !== void 0 && (_o$a$b3 = o.a.b) !== null && _o$a$b3 !== void 0 && _o$a$b3.c.d); | ||
} | ||
static testIfDeep(o) { | ||
var _o$obj; | ||
if ((_o$obj = o.obj) !== null && _o$obj !== void 0 && (_o$obj = _o$obj.a.b) !== null && _o$obj !== void 0 && _o$obj.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testConditionalDeep(o) { | ||
var _o$obj2; | ||
return (_o$obj2 = o.obj) !== null && _o$obj2 !== void 0 && (_o$obj2 = _o$obj2.a.b) !== null && _o$obj2 !== void 0 && _o$obj2.c.d ? true : false; | ||
} | ||
static testLoopDeep(o) { | ||
var _o$obj3; | ||
while ((_o$obj3 = o.obj) !== null && _o$obj3 !== void 0 && _o$obj3.a.b.c.d) { | ||
var _o$obj4; | ||
for (; (_o$obj4 = o.obj) !== null && _o$obj4 !== void 0 && (_o$obj4 = _o$obj4.a.b.c) !== null && _o$obj4 !== void 0 && _o$obj4.d;) { | ||
var _o$obj5; | ||
let i = 0; | ||
do { | ||
i++; | ||
if (i === 2) { | ||
return true; | ||
} | ||
} while ((_o$obj5 = o.obj) !== null && _o$obj5 !== void 0 && (_o$obj5 = _o$obj5.a.b) !== null && _o$obj5 !== void 0 && _o$obj5.c.d); | ||
} | ||
} | ||
return false; | ||
} | ||
static testNegateDeep(o) { | ||
var _o$obj6; | ||
return !!((_o$obj6 = o.obj) !== null && _o$obj6 !== void 0 && (_o$obj6 = _o$obj6.a.b) !== null && _o$obj6 !== void 0 && _o$obj6.c.d); | ||
} | ||
static testLogicalInIf(o) { | ||
var _o$a$b4, _o$a; | ||
if (o !== null && o !== void 0 && (_o$a$b4 = o.a.b) !== null && _o$a$b4 !== void 0 && _o$a$b4.c.d && o !== null && o !== void 0 && (_o$a = o.a) !== null && _o$a !== void 0 && _o$a.b.c.d) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
static testLogicalInReturn(o) { | ||
var _o$a$b5, _o$a2; | ||
return (o === null || o === void 0 || (_o$a$b5 = o.a.b) === null || _o$a$b5 === void 0 ? void 0 : _o$a$b5.c.d) && (o === null || o === void 0 || (_o$a2 = o.a) === null || _o$a2 === void 0 ? void 0 : _o$a2.b.c.d); | ||
} | ||
static testNullishCoalescing(o) { | ||
var _o$a$b$c$non_existent, _o$a$b6, _o$a$b7, _o$a$b$c$non_existent3, _o$a$b10; | ||
if ((_o$a$b$c$non_existent = o === null || o === void 0 || (_o$a$b6 = o.a.b) === null || _o$a$b6 === void 0 ? void 0 : _o$a$b6.c.non_existent) !== null && _o$a$b$c$non_existent !== void 0 ? _o$a$b$c$non_existent : o === null || o === void 0 || (_o$a$b7 = o.a.b) === null || _o$a$b7 === void 0 ? void 0 : _o$a$b7.c.d) { | ||
var _o$a$b$c$non_existent2, _o$a$b8, _o$a$b9; | ||
return (_o$a$b$c$non_existent2 = o === null || o === void 0 || (_o$a$b8 = o.a.b) === null || _o$a$b8 === void 0 ? void 0 : _o$a$b8.c.non_existent) !== null && _o$a$b$c$non_existent2 !== void 0 ? _o$a$b$c$non_existent2 : o === null || o === void 0 || (_o$a$b9 = o.a.b) === null || _o$a$b9 === void 0 ? void 0 : _o$a$b9.c.d; | ||
} | ||
return (_o$a$b$c$non_existent3 = o === null || o === void 0 || (_o$a$b10 = o.a.b) === null || _o$a$b10 === void 0 ? void 0 : _o$a$b10.c.non_existent) !== null && _o$a$b$c$non_existent3 !== void 0 ? _o$a$b$c$non_existent3 : o; | ||
} | ||
} | ||
C.test(); | ||
C.testNullish(); |
6 changes: 6 additions & 0 deletions
6
...shots/babel-plugin-transform-optional-chaining/test/fixtures/general/containers/output.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,6 @@ | ||
var _user$address, _user$address2, _a, _a2, _a3; | ||
var street = (_user$address = user.address) === null || _user$address === void 0 ? void 0 : _user$address.street; | ||
street = (_user$address2 = user.address) === null || _user$address2 === void 0 ? void 0 : _user$address2.street; | ||
test((_a = a) === null || _a === void 0 ? void 0 : _a.b, 1); | ||
test((_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b, 1); | ||
1, (_a3 = a) !== null && _a3 !== void 0 && _a3.b, 2; |
4 changes: 4 additions & 0 deletions
4
...gin-transform-optional-chaining/test/fixtures/general/delete-in-function-params/output.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,4 @@ | ||
function f(x = (() => { | ||
var _a; | ||
return (_a = a()) === null || _a === void 0 || delete _a.b; | ||
})()) {} |
7 changes: 7 additions & 0 deletions
7
...snapshots/babel-plugin-transform-optional-chaining/test/fixtures/general/delete/output.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,7 @@ | ||
"use strict"; | ||
var _obj$a, _obj$b; | ||
const obj = { a: { b: 0 } }; | ||
let test = obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 || delete _obj$a.b; | ||
test = obj === null || obj === void 0 || delete obj.a.b; | ||
test = obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 || delete _obj$b.b; | ||
obj === null || obj === void 0 || delete obj.a; |
5 changes: 5 additions & 0 deletions
5
...el-plugin-transform-optional-chaining/test/fixtures/general/function-call-loose/output.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,5 @@ | ||
var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar; | ||
(_foo = foo) === null || _foo === void 0 || _foo(foo); | ||
(_foo2 = foo) === null || _foo2 === void 0 || _foo2.bar(); | ||
(_foo$bar = (_foo3 = foo).bar) === null || _foo$bar === void 0 || _foo$bar.call(_foo3, foo.bar, false); | ||
(_foo4 = foo) === null || _foo4 === void 0 || (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 || _foo4$bar.call(_foo4, foo.bar, true); |
5 changes: 5 additions & 0 deletions
5
...l-plugin-transform-optional-chaining/test/fixtures/general/function-call-spread/output.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,5 @@ | ||
var _a, _a2, _a3, _a4; | ||
(_a = a) === null || _a === void 0 || _a(...args); | ||
(_a2 = a) === null || _a2 === void 0 || _a2.b(...args); | ||
(_a3 = a) === null || _a3 === void 0 || _a3.b(...args).c; | ||
(_a4 = a) === null || _a4 === void 0 || _a4.b(...args).c(...args); |
11 changes: 11 additions & 0 deletions
11
...ts/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call/output.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,11 @@ | ||
var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo$bar2, _foo7, _foo$bar3, _foo8, _foo9, _foo9$bar, _foo10, _foo10$bar; | ||
(_foo = foo) === null || _foo === void 0 || _foo(foo); | ||
(_foo2 = foo) === null || _foo2 === void 0 || _foo2.bar(); | ||
(_foo$bar = (_foo3 = foo).bar) === null || _foo$bar === void 0 || _foo$bar.call(_foo3, foo.bar, false); | ||
(_foo4 = foo) === null || _foo4 === void 0 || (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 || _foo4$bar.call(_foo4, foo.bar, true); | ||
(_foo5 = foo) === null || _foo5 === void 0 || _foo5().bar; | ||
(_foo6 = foo) === null || _foo6 === void 0 || (_foo6 = _foo6()) === null || _foo6 === void 0 || _foo6.bar; | ||
(_foo$bar2 = (_foo7 = foo).bar) === null || _foo$bar2 === void 0 || _foo$bar2.call(_foo7).baz; | ||
(_foo$bar3 = (_foo8 = foo).bar) === null || _foo$bar3 === void 0 || (_foo$bar3 = _foo$bar3.call(_foo8)) === null || _foo$bar3 === void 0 || _foo$bar3.baz; | ||
(_foo9 = foo) === null || _foo9 === void 0 || (_foo9$bar = _foo9.bar) === null || _foo9$bar === void 0 || _foo9$bar.call(_foo9).baz; | ||
(_foo10 = foo) === null || _foo10 === void 0 || (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 || (_foo10$bar = _foo10$bar.call(_foo10)) === null || _foo10$bar === void 0 || _foo10$bar.baz; |
19 changes: 19 additions & 0 deletions
19
...ugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.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,19 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) === null || _x === void 0 ? void 0 : _x.y; | ||
})()) {} | ||
function g({ a, b = (() => { | ||
return a === null || a === void 0 ? void 0 : a.c; | ||
})() }) {} | ||
function h(a, { b = (() => { | ||
var _a$b; | ||
return (_a$b = a.b) === null || _a$b === void 0 || (_a$b = _a$b.c) === null || _a$b === void 0 ? void 0 : _a$b.d.e; | ||
})() }) {} | ||
function i(a, { b = (() => { | ||
var _a$b2; | ||
return (_a$b2 = a.b) === null || _a$b2 === void 0 || (_a$b2 = _a$b2.c) === null || _a$b2 === void 0 ? void 0 : _a$b2.d; | ||
})().e }) {} | ||
function j(a, { b = (() => { | ||
var _a$b3; | ||
return a === null || a === void 0 || (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e; | ||
})() }) {} |
19 changes: 19 additions & 0 deletions
19
...bel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.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,19 @@ | ||
function f(a = (() => { | ||
var _x; | ||
return (_x = x) === null || _x === void 0 ? void 0 : _x.y; | ||
})()) {} | ||
function g({ a, b = (() => { | ||
return a === null || a === void 0 ? void 0 : a.c; | ||
})() }) {} | ||
function h(a, { b = (() => { | ||
var _a$b; | ||
return (_a$b = a.b) === null || _a$b === void 0 || (_a$b = _a$b.c) === null || _a$b === void 0 ? void 0 : _a$b.d.e; | ||
})() }) {} | ||
function i(a, { b = (() => { | ||
var _a$b2; | ||
return (_a$b2 = a.b) === null || _a$b2 === void 0 || (_a$b2 = _a$b2.c) === null || _a$b2 === void 0 ? void 0 : _a$b2.d; | ||
})().e }) {} | ||
function j(a, { b = (() => { | ||
var _a$b3; | ||
return a === null || a === void 0 || (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e; | ||
})() }) {} |
3 changes: 3 additions & 0 deletions
3
...el-plugin-transform-optional-chaining/test/fixtures/general/in-method-key-loose/output.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,3 @@ | ||
var _x$y; | ||
let x; | ||
const a = { [(_x$y = x.y) === null || _x$y === void 0 ? void 0 : _x$y.z]() {} }; |
3 changes: 3 additions & 0 deletions
3
...ts/babel-plugin-transform-optional-chaining/test/fixtures/general/in-method-key/output.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,3 @@ | ||
var _x$y; | ||
let x; | ||
const a = { [(_x$y = x.y) === null || _x$y === void 0 ? void 0 : _x$y.z]() {} }; |
2 changes: 2 additions & 0 deletions
2
...l-plugin-transform-optional-chaining/test/fixtures/general/in-var-destructuring/output.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,2 @@ | ||
var _x; | ||
var { a = (_x = x) === null || _x === void 0 ? void 0 : _x.y } = {}; |
Oops, something went wrong.