Traverse into type annotations
See original GitHub issueCurrently, we are not traversing into type annotations for either Flow or TypeScript. This is because the nodes on which these properties exist (Identifier
, FunctionDeclaration
, etc.) are already defined with a set number of children inside of escope
, and so it doesn’t search for unknown properties.
Now that we are doing more with type annotations, and the location of type annotation information is more or less standardized for ESTree. I think we should add traversing of these properties. This would basically be:
Identifier.typeAnnotation
FunctionDeclaration.returnType
FunctionExpression.returnType
ArrowFunctionExpression.returnType
MethodDefinition.returnType
We can modify how escope
traverses to include these extra properties.
Breaking: This is a breaking change because changing the traversal depth could have unintended side effects on core or custom rules.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Can an `ElementVisitor` be used to traverse the statements in ...
After reading the @TypeQualifierDefault 's description, “to denote that the annotation defines a default type qualifier that is visible within ...
Read more >Bringing macros to Python by abusing type annotations
Now I know I can store information in type annotations, ... then traverse the tree looking for things that have the annotation "this...
Read more >Collect in Rust, traverse in Haskell and Scala - FP Complete
In this post, we'll analyze the collect method in Rust, powered by the Iterator and FromIterator traits, together with a comparison against ...
Read more >Moving Types - TypeScript Deep Dive - Gitbook
You can actually use a variable in a type annotation using the typeof operator. ... You can traverse into any non-nullable object type...
Read more >Understanding type inference · F# for Fun and Profit - swlaschin
Annotate as needed. One common trick is to add annotations until everything works, and then take them away one by one until you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the 2016-09-15 TSC meeting, we decided to add traversals for type annotations and decorators in v4.0.
PR up!