@babel/eslint-parser: fix ImportExpression node to match ESTree spec #10828
@babel/eslint-parser: fix ImportExpression node to match ESTree spec #10828nicolo-ribaudo merged 8 commits intobabel:masterfrom
Conversation
a9dca47 to
e51ed79
Compare
e8fbad0 to
2b0b1ee
Compare
| `); | ||
| }); | ||
|
|
||
| it("Dynamic Import", () => { |
There was a problem hiding this comment.
Nice to be able to test this across the parser and the estree plugin :)
|
Wrestling with some Flow types right now (I haven't used Flow in years 😬), but will hopefully have that fixed up soon. |
2bcbc0c to
c25b1e7
Compare
|
Still struggling with the flow types on this one (trying to avoid using |
|
The problem with flow is that a function returns |
ee14f2d to
93a3451
Compare
|
|
||
| // ImportExpressions do not have an arguments array. | ||
| toReferencedListDeep( | ||
| exprList: $ReadOnlyArray<?N.Expression> = [], |
There was a problem hiding this comment.
This was crashing because it's given the CallExpression's arguments array, which is undefined for ImportExpressions (deleted above).
There was a problem hiding this comment.
What about doing this? We avoid using the empty array and iterating it:
toReferencedListDeep(exprList: ?$ReadOnlyArray<?N.Expression>) {
if (exprList) return super.toReferencedListDeep(exprList);
}If flow complains that it can't return undefined, we can just change the original toReferencedListDeep signature to return void, since it's return value is never used.
There was a problem hiding this comment.
Sure, that sounds good to me. Updated!
575753b to
4a76f37
Compare
4a76f37 to
2e77d76
Compare
@babel/parsercurrently parses dynamic imports (import('a')) asCallExpressions (code here). The ESTree spec differs from this and gives it its own type calledImportExpression.