GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — Fix getTypeAtLocation for `as const` to not issue a diagnostic by weswigham · Pull Request #36741 · microsoft/TypeScript Conversation
|
| function getTypeFromTypeReference(node: TypeReferenceType): Type { | ||
| const links = getNodeLinks(node); | ||
| if (!links.resolvedType) { | ||
| // handle LS queries on the `const` in `x as const` by resolving to the type of `x` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Instead of this shouldn't getTypeOfNode just check if it is const of as const expression should forward it to correct node instead?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ehhhhhh, it could, but I'd rather push the handling to here, to prevent us from ever attempting to resolve the const in as const as a real type reference, however we may get there in the future (plus, by doing it here the result is cached).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Is this related to #36490? I believe that PR was also about handling LS requests in larger spans (i.e. not just on identifiers). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Not as far as I know - this is just about fixing us giving a bogus result (and adding a diagnostic) for the type of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So it changes from wrong to right, rather than from nothing to something? Makes sense. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
UsinggetTypeAtLocation on a const type reference creates a TS2304 diagnostic
There was an error while loading. Please reload this page.