Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Relevant Package
ast-spec
Playground Link
Repro Code
// This parses as a JSXExpressionContainer node whose expression is a JSXEmptyExpression node.<a>{}</a>;
ESLint Config
No response
tsconfig
No response
Expected Result
I expect that when using theAST_NODE_TYPES.JSXExpression type theAST_NODE_TYPES.JSXEmptyExpression won't be a member of the union.
Actual Result
What I see is that the definition of the union is:
exporttypeJSXExpression=|JSXEmptyExpression|JSXExpressionContainer|JSXSpreadChild;
Additional Info
Code like<a>{}</a> is parsed by typescript as aJsxExpression node who'sexpression value isundefined. As part of converting the JsxExpression node to an ESLint compatible AST, thetypescript-estree package replaces theundefined with aJSXEmptyExpression node (relevant code).
However, in theast-spec package theJSXEmptyExpression type is a part of theJSXExpression union (defined here). As explained above, this is incorrect as theJSXEmptyExpression node is only created as the child of a JSXExpression.
Versions
| package | version |
|---|---|
@typescript-eslint/ast-spec | 5.48.0 |
@typescript-eslint/typescript-estree | 5.48.0 |