question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Traverse into type annotations

See original GitHub issue

Currently, 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

6reactions
btmillscommented, Sep 15, 2016

In the 2016-09-15 TSC meeting, we decided to add traversals for type annotations and decorators in v4.0.

1reaction
kaicataldocommented, Mar 30, 2017

PR up!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found