Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The JSXExpression union incorrectly includes JSXEmptyExpression #6315

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: ast-specIssues related to @typescript-eslint/ast-spec
@MageJohn

Description

@MageJohn

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

https://typescript-eslint.io/play/#ts=4.3.5&jsx=true&sourceType=module&showAST=es&code=DwQwfA3gvsD04G4g&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

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

packageversion
@typescript-eslint/ast-spec5.48.0
@typescript-eslint/typescript-estree5.48.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: ast-specIssues related to @typescript-eslint/ast-spec

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp