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
Remove properties that are used by invalid code #4759
Comments
This comment was marked as resolved.
This comment was marked as resolved.
I intented to create an PR for this, but each of the properties seem to be intended as they are handled explicitly:
|
Yes it's implemented. But that doesn't mean it should be there! Some of this code was written by non-TS folks back in the day - who worked to just convert the AST 1-for-1 without know what was right or wrong. We should remove properties and the code that populates them! |
I was about to submit a PR to this issue, but I stumbled upon a realization: there are still valid modifiers, more specifically const and declare, to handle. I think the best approach to this problem is to modify the code in order to restrict and forbid invalid modifiers within these nodes instead of removing it. |
These are handled via boolean flags. typescript-eslint/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts Lines 11 to 12 in 18a81cb
typescript-eslint/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts Line 16 in 18a81cb
|
Another set of cases to be removed:
Syntactically the TS parser allows the |
Another case to be removed:
Syntactically the TS parser allows an initialiser (likely due to it reusing parsing logic for class properties), but semantically it is disallowed. |
Another case to be removed:
|
Fixed by #4863 and will be available in v6! 🚀 |
Currently we have the following AST properties declared:
typescript-eslint/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts
Line 13 in 8329498
typescript-eslint/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts
Line 25 in 8329498
typescript-eslint/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts
Line 14 in 8329498
typescript-eslint/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts
Line 15 in 8329498
These all represent bad code that would cause errors if one attempted to build in TS:
TS parses these fine and emits a semantic error, not a syntactic error.
Our parser currently does not error on syntactically bad code, thus we also don't error on it (#1852).
We should remove these properties from the AST as it is non-sensical to include them - nobody should ever be inspecting the code that is produced on them.
The text was updated successfully, but these errors were encountered: