AST naming convention #2051
Replies: 11 comments 13 replies
-
Thanks @ematipico for going through all the names and assembling this list! I'll create separate comments to make the discussion easier
I don't think it adds any clarity to people reading code using the AST nodes and just adds some more characters to type. It isn't important for authors/readers to know that this is an auxiliary node. This is different from the The overall rule is that the postfix specifies to what group a node belongs. For example:
These go often along with a corresponding union:
|
Beta Was this translation helpful? Give feedback.
-
These are |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I wouldn't postfix these with |
Beta Was this translation helpful? Give feedback.
-
Simply auxiliary nodes. Don't belong to a bigger scheme. |
Beta Was this translation helpful? Give feedback.
-
This is an identifier referencing a name from the scope and not a binding of a new identifier. It's an auxiliary node that is necessary because there are places where an identifier references a name besides the |
Beta Was this translation helpful? Give feedback.
-
Postfixing the node with |
Beta Was this translation helpful? Give feedback.
-
These are neither assignments nor patterns but elements of an array or object assignment. But I agree, the names are a bit out of place:
But that might be a bit of a mouthful. Also,
Same as for assignment |
Beta Was this translation helpful? Give feedback.
-
The items aren't a module but a |
Beta Was this translation helpful? Give feedback.
-
Same for exports: I think you're right that it would be more consistent if the |
Beta Was this translation helpful? Give feedback.
-
Some feedback about the AST:
|
Beta Was this translation helpful? Give feedback.
-
This is a follow up of #1868
Now that we have a good coverage of the JS syntax and we managed to express all the syntax, I wanted to open a small discussion to propose some changes to the current names of our AST nodes.
Here's a list of the AST nodes that I found incorrect/incoherent and a possible proposal of change/question:
JsUnknownImportAssertionEntry
JsUnknownNamedImportSpecifier
This should have
Import
at the end;JsElseClause
JsAnySwitchClause
JsDefaultClause
Probably these are exceptions? Should we add
Auxiliary
at the end?JsCatchDeclaration
JsVariableDeclaration
JsForVariableDeclaration
We don't have the
Declaration
conception. Should it beStatement
? OrAuxiliary
?JsSpread
JsArrayHole
Should we add
Auxiliary
at the end?JsReferenceIdentifier
Should this be
Binding
at the end?JsAssignmentWithDefault
Maybe this should become
JsWithDefaultAssignment
?JsArrayAssignmentPatternRestElement
JsObjectAssignmentPatternShorthandProperty
JsObjectAssignmentPatternProperty
JsObjectAssignmentPatternRest
JsArrayBindingPatternRestElement
Are these
Assignment
orPattern
? They should have their concept at the end of their name.JsObjectBindingPatternProperty
JsObjectBindingPatternRest
JsObjectBindingPatternShorthandProperty
Probably, we should move
BindingPattern
at the end`JsAnyModuleItem
Probably,
Module
should be at the end.AnyJsImportClause
JsImportBareClause
JsImportNamedClause
JsImportDefaultClause
JsImportNamespaceClause
TsImportRequireClause
TsImportAliasClause
JsImportAssertion
JsDefaultImportSpecifier
Probably, we should move
Import
at the end of their name.JsAnyExportClause
JsExportFunctionClause
JsExportDefaultFunctionClause
JsExportClassClause
JsExportDefaultClassClause
JsExportVariableClause
JsExportDefaultExpressionClause
JsExportNamedClause
JsExportFromClause
JsExportNamedFromClause
Probably, we should move
Export
at the end of their nameMaybe we should add
Auxiliary
at the end of each name? Just a proposal, I don't thinkBeta Was this translation helpful? Give feedback.
All reactions