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

Enhancement: add strictparent types for nodes that have well-defined parents #10682

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
@ronami

Description

@ronami

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

types

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

This PR is a very similar proposal to the one in#6225 and suggests having stricterparent types for some AST nodes:

  • ExportDefaultDeclaration has parentTSESTree.BlockStatement | TSESTree.Program | TSESTree.TSModuleBlock
  • ExportNamedDeclaration has parentTSESTree.BlockStatement | TSESTree.Program | TSESTree.TSModuleBlock
  • FunctionDeclaration withname has parentTSESTree.BlockStatement | TSESTree.ExportDefaultDeclaration | TSESTree.ExportNamedDeclaration | TSESTree.Program.
  • FunctionDeclaration withoutname has parentTSESTree.ExportDefaultDeclaration (reference).

This is a follow-up to the discussion in#10422 (comment).


Some thoughts/notes:

  • I've looked into@babel/parser,@swc/types, and@oxc-project/types (also the more technical1,2), but I didn't find anything that makes me confident this is valid in every case. I verified that@typescript-eslint itself is type-checked successfully with these assumptions.
  • TypeScript itself doesn't have a specificparent forFunctionDeclaration (it falls back to the genericts.Node), although they do have stricter parent types for some other nodes.
  • To my understanding, TypeScript's AST doesn't have an actual AST node forExportDefaultDeclaration orExportNamedDeclaration, as they're expressed asmodifiers.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    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