Resolve the context sensitive expression containers before resolving node#1362
Conversation
…ve expression Handles #1165
…ontext sensitive information before resolving the actual node
There was a problem hiding this comment.
why getNarrowedType here, but not above?
There was a problem hiding this comment.
I will add inline comment too.. but this is because getTypeOfNode by default does narrowing and gets it correctly. But if you just gettype of symbol it wouldn't be narrowed. It needs node at which you are trying to get type of symbol so that it can decide if it can decide when and how to narrow the type.
eg. consider this:
function foo(a: string | number) {
if (typeof a === "string") {
a/**/
}
}
The symbol of a is a parameter symbol. and if you can getTypeOfSymbol then it would be string | number because there is no node information specified
But if you tell I want type of a at the /**/ location it can decide to narrow it to "string"
|
👍 |
Resolve the context sensitive expression containers before resolving node
When trying to get type/symbol information of the location, make sure that its context sensitive expression containers are resolved in top down manner to avoid incorrectly making something any because of recursive recursion that can occur during resolution.
Fixes #1165