-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Resuscitate the SymbolWalker API #17844
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
Conversation
@amcasey, |
I must have missed my test cleanup when I rebased. Just a minute... |
src/compiler/symbolWalker.ts
Outdated
function visitObjectType(type: ObjectType): void { | ||
const stringIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); | ||
visitType(stringIndexType); | ||
const numberIndexType = getIndexTypeOfStructuredType(type, IndexKind.String); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weswigham Is that supposed to be IndexKind.Number
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
src/compiler/symbolWalker.ts
Outdated
@@ -0,0 +1,173 @@ | |||
/** @internal */ | |||
namespace ts { | |||
/** @internal */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to do this twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered. Presumably, the inner one is redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think visitType
needs clauses for visiting the related types for index types, index access types, and mapped types - those are new since its original writing, so it doesn't handle them yet, from the look of it.
The travis failure is unrelated. The PR is here: ivogabe/gulp-typescript#536. |
src/compiler/symbolWalker.ts
Outdated
} | ||
} | ||
|
||
function leftmostSymbol(expr: QualifiedName | Identifier): Symbol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can probably just be implemented as getResolvedSymbol(getFirstIdentifier(expr))
, if you're willing to have getFirstIdentifier
from the checker as a parameter.
...until required by an external consumer.
1. Expose visited types and symbols 2. Automatically reset before each walk
...to consume revised API.
Closing and re-opening to re-queue tests. |
@amcasey, |
Resuscitate the SymbolWalker API
All the good bits are from @weswigham (PR #9847). I just tweaked the API and made everything internal.