Skip TSAsExpression when transforming spread in CallExpression (#11404)
* Skip TSAsExpression when transforming spread in CallExpression * Create @babel/helper-get-call-context package * Support OptionalCallExpressions * Use helper in optional chaining plugin, and move tests * Update package.json files * Use dot notation to access property * Remove private method tests until future MR * Update packages/babel-plugin-transform-spread/package.json * Rename @babel/helper-get-call-context to @babel/helper-skip-transparent-expr-wrappers * Handle typed OptionalMemberExpressions * Make @babel/helper-skip-transparent-expr-wrappers a dependency * Support TSNonNullExpressions * Use named import instead of default * Add test for call context when parenthesized call expression has type * Improve handling of member expressions inside transparent expression wrappers * Add comment explaining what a transparent expression wrapper is * Add newlines to test fixtures * Pass correct parameter type to skipTransparentExprWrappers * Rename to babel-helper-skip-transparent-expression-wrappers * Remove getCallContext helper * Fixed exports key * Preserve types in babel-plugin-transform-spread tests * Use external-helpers to avoid inlining helper functions in tests Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
var _a, _a2, _a3, _b, _a4, _ref, _a5, _c, _a6, _a7;
|
||||
var _a, _a2, _a3, _b, _a4, _a4$b, _a5, _c, _a6, _a7;
|
||||
|
||||
(_a = a) === null || _a === void 0 ? void 0 : _a.b!.c;
|
||||
(_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b!.c.d;
|
||||
(_a3 = a) === null || _a3 === void 0 ? void 0 : _a3.b.c!.d;
|
||||
(_b = a!.b) === null || _b === void 0 ? void 0 : _b.c;
|
||||
(_a4 = a) === null || _a4 === void 0 ? void 0 : (_ref = _a4.b!) === null || _ref === void 0 ? void 0 : _ref.c;
|
||||
(_a4 = a) === null || _a4 === void 0 ? void 0 : (_a4$b = _a4.b!) === null || _a4$b === void 0 ? void 0 : _a4$b.c;
|
||||
(_a5 = a) === null || _a5 === void 0 ? void 0 : (_c = _a5.b!.c) === null || _c === void 0 ? void 0 : _c.c;
|
||||
((_a6 = a) === null || _a6 === void 0 ? void 0 : _a6.b)!.c;
|
||||
((_a7 = a) === null || _a7 === void 0 ? void 0 : _a7.b)!.c;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
var _a, _a2, _a3, _b, _a4, _ref, _a5, _c, _a6, _a7;
|
||||
var _a, _a2, _a3, _b, _a4, _a4$b, _a5, _c, _a6, _a7;
|
||||
|
||||
(_a = a) === null || _a === void 0 ? void 0 : _a.b.c;
|
||||
(_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b.c.d;
|
||||
(_a3 = a) === null || _a3 === void 0 ? void 0 : _a3.b.c.d;
|
||||
(_b = a.b) === null || _b === void 0 ? void 0 : _b.c;
|
||||
(_a4 = a) === null || _a4 === void 0 ? void 0 : (_ref = _a4.b) === null || _ref === void 0 ? void 0 : _ref.c;
|
||||
(_a4 = a) === null || _a4 === void 0 ? void 0 : (_a4$b = _a4.b) === null || _a4$b === void 0 ? void 0 : _a4$b.c;
|
||||
(_a5 = a) === null || _a5 === void 0 ? void 0 : (_c = _a5.b.c) === null || _c === void 0 ? void 0 : _c.c;
|
||||
((_a6 = a) === null || _a6 === void 0 ? void 0 : _a6.b).c;
|
||||
((_a7 = a) === null || _a7 === void 0 ? void 0 : _a7.b).c;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["proposal-optional-chaining"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
(a.b as any)?.()
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"syntax-typescript"
|
||||
],
|
||||
[
|
||||
"proposal-optional-chaining"
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var _a$b, _a;
|
||||
|
||||
(_a$b = ((_a = a).b as any)) === null || _a$b === void 0 ? void 0 : _a$b.call(_a);
|
||||
@@ -0,0 +1 @@
|
||||
(((foo as A).bar) as B)?.(foo.bar, false)
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"syntax-typescript"
|
||||
],
|
||||
[
|
||||
"proposal-optional-chaining",
|
||||
{
|
||||
"loose": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var _bar, _ref;
|
||||
|
||||
(_bar = ((_ref = (foo as A)).bar as B)) == null ? void 0 : _bar.call(_ref, foo.bar, false);
|
||||
@@ -0,0 +1 @@
|
||||
(a?.b as ExampleType)?.c as ExampleType2
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"syntax-typescript"
|
||||
],
|
||||
[
|
||||
"proposal-optional-chaining"
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var _a, _a$b;
|
||||
|
||||
(((_a = a) === null || _a === void 0 ? void 0 : (_a$b = (_a.b as ExampleType)) === null || _a$b === void 0 ? void 0 : _a$b.c) as ExampleType2);
|
||||
@@ -0,0 +1 @@
|
||||
((o?.Foo.m) as ExampleType)()
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"plugins": [
|
||||
[
|
||||
"syntax-typescript"
|
||||
],
|
||||
[
|
||||
"proposal-optional-chaining"
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var _o, _o$Foo;
|
||||
|
||||
(((_o = o) === null || _o === void 0 ? void 0 : (_o$Foo = _o.Foo).m.bind(_o$Foo)) as ExampleType)();
|
||||
Reference in New Issue
Block a user