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:
Oliver Dunk
2020-07-30 19:17:37 +01:00
committed by GitHub
parent 32e7bb4027
commit db56261414
36 changed files with 224 additions and 33 deletions

View File

@@ -0,0 +1 @@
(a.b: any)(...args)

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-spread", "syntax-flow"]
}

View File

@@ -0,0 +1,3 @@
var _a;
((_a = a).b: any).apply(_a, babelHelpers.toConsumableArray(args));

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-spread", "transform-parameters"]
}

View File

@@ -0,0 +1,5 @@
{
"parserOpts": {
"createParenthesizedExpressions": true
}
}

View File

@@ -0,0 +1,3 @@
var _a;
((_a = a).b).apply(_a, babelHelpers.toConsumableArray(args));

View File

@@ -0,0 +1 @@
(<any> a.b)(...args)

View File

@@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "transform-spread", "syntax-typescript"]
}

View File

@@ -0,0 +1,3 @@
var _a;
(<any> (_a = a).b).apply(_a, babelHelpers.toConsumableArray(args));

View File

@@ -0,0 +1 @@
(dog.bark as any)(...args)

View File

@@ -0,0 +1,7 @@
{
"presets": [
[
"typescript"
]
]
}

View File

@@ -0,0 +1,3 @@
var _dog;
(_dog = dog).bark.apply(_dog, babelHelpers.toConsumableArray(args));