mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
Don't crash when renaming a JS property declared via module.exports (#40297)
Fixes #38070 When the originating definition was of the form ```js module.exports.foo = expr ``` we were incorrectly trying to call `resolveName` on just the `foo` portion to get the "local" symbol, which simply failed to resolve (or would have resolved to the wrong thing), but for this form, the local symbol is just the containing property access expression
This commit is contained in:
@@ -644,7 +644,8 @@ namespace ts.FindAllReferences {
|
||||
return checker.getExportSpecifierLocalTargetSymbol(declaration)!;
|
||||
}
|
||||
else if (isPropertyAccessExpression(declaration) && isModuleExportsAccessExpression(declaration.expression) && !isPrivateIdentifier(declaration.name)) {
|
||||
return checker.getExportSpecifierLocalTargetSymbol(declaration.name)!;
|
||||
// Export of form 'module.exports.propName = expr';
|
||||
return checker.getSymbolAtLocation(declaration)!;
|
||||
}
|
||||
else if (isShorthandPropertyAssignment(declaration)
|
||||
&& isBinaryExpression(declaration.parent.parent)
|
||||
|
||||
Reference in New Issue
Block a user