Enhancement: add strict parent
types for nodes that have well-defined parents
#10682
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement
New feature or request
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Uh oh!
There was an error while loading. Please reload this page.
Before You File a Proposal Please Confirm You Have Done The Following...
Relevant Package
types
My proposal is suitable for this project
Description
This PR is a very similar proposal to the one in #6225 and suggests having stricter
parent
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:
@babel/parser
,@swc/types
, and@oxc-project/types
(also the more technical 1, 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.parent
forFunctionDeclaration
(it falls back to the genericts.Node
), although they do have stricter parent types for some other nodes.ExportDefaultDeclaration
orExportNamedDeclaration
, as they're expressed asmodifiers
.Additional Info
No response
The text was updated successfully, but these errors were encountered: