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
Fix bugs in AST description #192
Comments
It seems like universally my comments below are that you're trying to make assumptions about the ESTree spec that aren't things that have been goals of this project. This project began as a way of taking an existing implementation and specifying it so other projects could aim to conform to it. It is not aimed at being a statically-typed context-free structure, and is not aimed at Flow or TS. While those certainly are things that it could have aimed for, at this point it would require major breaking changes.
They are not incompatible because the
Same here.
It is not clear what you mean here. Where do Typescript and Flow come into this picture?
Why is this an issue? Even in JS, reserved words are allowed as property names.
While the DSL could probably be clearer, I think it's pretty easy to say that any type with an explicit string
Context is required in several ways when processing patterns. For instance, |
I didn't go far to look up that it aims to be
and the fact that developing tools with this standard in mind is a pain is not an assumption. Then I created this issue.
While renaming
It's only valid to override a type with a supertype in this covariant context. Current override breaks LSP. If common definition of inheritance is discarded, it should be mentioned in documentation. The proper approach is to have a supertype, the same way as with
Same here.
Where
This is another unnecessary issue of tool implementation. You cannot name argument or local variable
If this phrase was normative, I could have arbitrary value
Inapplicable here. It's fine to reuse node types. This exact case requires a 1-deep context. Take a look at the example. |
This repository uses a simple DSL to define structural types for the AST. The inheritance described here is purely structural inheritance for the sake of avoiding repetition. It is not a definition of a class hierarchy for AST node types themselves.
What specifically would be gained by enumerating this in the specification rather than having it be implicit based on the presence of a string-literal
Again, this assumes that the types in the spec are meant to behave as a type hierarchy for user code, which is not the case.
I don't follow what you mean by this. |
It would be quite unfortunate if people had to find this issue to figure it out. Could you please add description of "structural inheritance" into standard?
Ability to use
No, it doesn't assume anything except for what you previously said: a node should have a
It means so only with your interpretation of it. You cannot give automated tools human-readable interpretation and expect it to figure out correct code somehow.
I mean that in this exact case there has to be a superclass |
The README already says that it uses a custom syntax to describe its structures, so I don't think it's reasonable to expect it to behave like TypeScript or Flow or some other specific language.
That's what autogenerated https://github.com/estree/formal is intended for. The ESTree spec itself, like ECMAScript syntax spec, is not intended for machine-readable consumers but rather for implementers (humans). And if you're looking for just TypeScript checks, then it's best to use version from DefinitelyTyped which tries to address most (all?) of your mentioned concerns in the best way possible for TypeScript specifically.
babel-types couldn't be generated from the grammar either way because Babel doesn't follow ESTree (it uses a custom fork of spec with somewhat different rules).
Yep, generally that's the intention. Whether the tool can handle specific type of node or not is a separate matter, but in practice it's fine to expect anything containing |
ForOfStatement
should not inherit fromForInStatement
due to incompatibletype
s. It was at some point of time fixed forNewExpression
which inherited fromCallExpression
and had incompatibletype
's type.Same for
ArrowFunctionExpression
that extendsFunction
and has incompatiblebody
type.Function
should be renamed not to clash withFunction
type of Typescript and Flow.CallExpression
has property namedarguments
which is a reserved wordMethodDefinition
has property namedstatic
which is a reserved wordConsider deprecating these names in favor of
args
andisStatic
.(At least)
Class
,Function
,Node
,Pattern
,Expression
,Declaration
andStatement
are not AST nodes, and it's not marked in any way. One could have thought that AST nodes are distinguished by having atype
, butNode
hastype
and is not an AST node. Consider deprecating these in favor of unions:AssignmentProperty
incorrectly inherits fromProperty
. Even though it hastype: 'Property'
, it's a different AST node that accidentally got the same name, and has to be distinguished by context. It can haveObjectPattern
in its value, butPattern
requiresvalue
to be anExpression
. They should probably have common ancestor.I've attempted to fix a legacy version of
estree
used forestree/formal
project by renaming non-AST nodes to haveAbstract
in their names.The text was updated successfully, but these errors were encountered: