-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Differentiate AST node types without parent (for estree) and with parent (for eslint) #8347
Comments
Note that changing the types of one without the other wouldn't fix the related problem in the ESLint types. The signature for a parser includes both functions. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eslint/index.d.ts#L1182-L1187
This is my preference. As I stated in the other thread I don't think that there's any value in making parsers passed to the ESLint config type adhere to a strict shape beyond the basic TBH Parser's default options should be updated to match the options eslint passes in and we should remove the options entirely. Things break if you don't pass those options in - eg our scope analyser assumes certain options are set. |
Oh! Reducing complexity that way did not occur to me as something we can do. I love it. But, are there any ecosystem consumers that expect the properties be set? cc @fisker and ... I don't know who else to tag 🤔 |
There's a difference between The former was only ever intended for use with eslint and the latter is a generic thing to be used by whatever. |
So just to be clear: is your proposal that |
#8617 was merged into |
Before You File a Proposal Please Confirm You Have Done The Following...
Relevant Package
parser
My proposal is suitable for this project
Description
Spinning out of DefinitelyTyped/DefinitelyTyped#68232: right now, the types for ASTs generated by
@typescript-eslint/parser
have "one size fits all" types. DefinitelyTyped/DefinitelyTyped#68232 (comment):One tricky thing is that for the sake of simplicity I don't think we want to make custom lint rule users have to see type parameters & optionality pop up all over the place in their AST. I think we'll want to have two ASTs that can be generated:
parse
: Utilizes the fancy new conditional types to make the AST shapes more preciseparseForESLint
: Avoids the fancy new conditional types and uses the same existing non-generic versions of AST nodesI think we can get there with the following changes:
NodeOrTokenData
an type parameter object for whether it hasloc
and/orrange
types/src/generated/ast-spec.ts
, create a second version of the nodes with that same type parameter object - i.e.ParsedProgram<* extends *> extends NodeOrTokenData<*>
parse
configurable with that new type parameter objectparse
's return type use a newParseResult
interface that forwards that type parameter object to its AST nodesParseForESLintResult
or other rule infrastructure: it returns the same nodes as beforeI.e. we'd be making a new set of node types that users of
parse
now see, without changingparseForESLint
or custom rules.Additional Info
No response
The text was updated successfully, but these errors were encountered: