-
Notifications
You must be signed in to change notification settings - Fork 15
Adjust usage #368
8000New 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
Adjust usage #368
Conversation
|
|
||
const parent = node.parent; | ||
const parent = declaration; | ||
if (ts.isVariableDeclaration(parent)) { |
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.
If I'm not mistaken, this is now redundant with getValueOfValueDeclaration
. Unless we have extra logic for the discovered node (which shouldn't be called parent
any longer but just declaration
/ valueDeclaration
here, we can just use getValueOfValueDeclaration
and do further operations separately, basically on:
- valueDeclarationNode
- valueNode
As long as tests pass, we can adjust this manually in a future PR
This change will cover more edge cases though once adjusted as per the above
|
||
const def = definitions && definitions[0]; | ||
if (!def) return; | ||
const typeChecker = info.languageService.getProgram()?.getTypeChecker(); |
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 is awkwardly repeated now across the codebase. We can manually refactor our helper functions to just accept the typeChecker
directly now afaict
if (!checker) return null; | ||
|
||
const definitions = info.languageService.getDefinitionAtPosition( | ||
element.getSourceFile().fileName, | ||
element.getStart() | ||
); | ||
const value = getValueOfIdentifier(input, checker); | ||
if (!value) return null; |
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.
nit: redundant null
conversions, which can be avoided if we adjust signatures here
identifier = typeQuery.exprName; | ||
} else if (ts.isQualifiedName(typeQuery.exprName)) { | ||
// For qualified names like 'module.identifier', get the right-most identifier | ||
identifier = typeQuery.exprName.right; |
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.
nit: This seems a bit suspect. I don't remember fully what the intention here is, but I assume it's type casts? We may not be covering all edge cases here, if we do, this qualifies for making a helper and adding some comments
No description provided.