mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 12:57:11 -06:00
Properly handle both special export forms when renaming (#36914)
* Properly handle both special export forms when renaming Fixes #36713 * Lint
This commit is contained in:
parent
3bec9ad2c5
commit
2b69b2281a
@ -5009,6 +5009,14 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression;
|
||||
}
|
||||
|
||||
export function getNameOfAccessExpression(node: AccessExpression) {
|
||||
if (node.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return node.name;
|
||||
}
|
||||
Debug.assert(node.kind === SyntaxKind.ElementAccessExpression);
|
||||
return node.argumentExpression;
|
||||
}
|
||||
|
||||
export function isBundleFileTextLike(section: BundleFileSection): section is BundleFileTextLike {
|
||||
switch (section.kind) {
|
||||
case BundleFileSectionKind.Text:
|
||||
|
||||
@ -517,7 +517,7 @@ namespace ts.FindAllReferences {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const sym = useLhsSymbol ? checker.getSymbolAtLocation(cast(node.left, isPropertyAccessExpression).name) : symbol;
|
||||
const sym = useLhsSymbol ? checker.getSymbolAtLocation(getNameOfAccessExpression(cast(node.left, isAccessExpression))) : symbol;
|
||||
// Better detection for GH#20803
|
||||
if (sym && !(checker.getMergedSymbol(sym.parent!).flags & SymbolFlags.Module)) {
|
||||
Debug.fail(`Special property assignment kind does not have a module as its parent. Assignment is ${Debug.formatSymbol(sym)}, parent is ${Debug.formatSymbol(sym.parent!)}`);
|
||||
|
||||
5
tests/baselines/reference/renameExportCrash.baseline
Normal file
5
tests/baselines/reference/renameExportCrash.baseline
Normal file
@ -0,0 +1,5 @@
|
||||
/*====== /tests/cases/fourslash/Foo.js ======*/
|
||||
|
||||
let RENAME;
|
||||
module.exports = [|RENAME|];
|
||||
exports["foo"] = RENAME;
|
||||
9
tests/cases/fourslash/renameExportCrash.ts
Normal file
9
tests/cases/fourslash/renameExportCrash.ts
Normal file
@ -0,0 +1,9 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: Foo.js
|
||||
//// let a;
|
||||
//// module.exports = /**/a;
|
||||
//// exports["foo"] = a;
|
||||
|
||||
verify.baselineRename("", { });
|
||||
Loading…
x
Reference in New Issue
Block a user