Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
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 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:
- I've looked into
@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. - TypeScript itself doesn't have a specific
parent
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 for
ExportDefaultDeclaration
orExportNamedDeclaration
, as they're expressed asmodifiers
.
Additional Info
No response