mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
@@ -472,7 +472,7 @@ namespace ts.refactor {
|
||||
if (isInImport(decl)) {
|
||||
oldImportsNeededByNewFile.add(symbol);
|
||||
}
|
||||
else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) {
|
||||
else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) {
|
||||
newFileImportsFromOldFile.add(symbol);
|
||||
}
|
||||
}
|
||||
@@ -614,7 +614,11 @@ namespace ts.refactor {
|
||||
interface TopLevelVariableDeclaration extends VariableDeclaration { parent: VariableDeclarationList & { parent: VariableStatement; }; }
|
||||
type TopLevelDeclaration = NonVariableTopLevelDeclaration | TopLevelVariableDeclaration;
|
||||
function isTopLevelDeclaration(node: Node): node is TopLevelDeclaration {
|
||||
return isNonVariableTopLevelDeclaration(node) || isVariableDeclaration(node) && isSourceFile(node.parent.parent.parent);
|
||||
return isNonVariableTopLevelDeclaration(node) && isSourceFile(node.parent) || isVariableDeclaration(node) && isSourceFile(node.parent.parent.parent);
|
||||
}
|
||||
|
||||
function sourceFileOfTopLevelDeclaration(node: TopLevelDeclaration): Node {
|
||||
return isVariableDeclaration(node) ? node.parent.parent.parent : node.parent;
|
||||
}
|
||||
|
||||
function isTopLevelDeclarationStatement(node: Node): node is TopLevelDeclarationStatement {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
////import './foo';
|
||||
////import { a, b, alreadyUnused } from './other';
|
||||
////const p = 0;
|
||||
////[|const y = p + b;|]
|
||||
////[|const y: Date = p + b;|]
|
||||
////a; y;
|
||||
|
||||
verify.moveToNewFile({
|
||||
@@ -20,7 +20,7 @@ a; y;`,
|
||||
"/y.ts":
|
||||
`import { b } from './other';
|
||||
import { p } from './a';
|
||||
export const y = p + b;`,
|
||||
export const y: Date = p + b;`,
|
||||
},
|
||||
|
||||
preferences: {
|
||||
|
||||
Reference in New Issue
Block a user