Let isolated declarations fixer add toplevel imports more (#60267)
This commit is contained in:
Родитель
79ea5a5b35
Коммит
c043944b14
|
@ -606,12 +606,10 @@ export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder:
|
|||
|
||||
/** @internal */
|
||||
export function typeNodeToAutoImportableTypeNode(typeNode: TypeNode, importAdder: ImportAdder, scriptTarget: ScriptTarget): TypeNode | undefined {
|
||||
if (typeNode && isImportTypeNode(typeNode)) {
|
||||
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
||||
if (importableReference) {
|
||||
importSymbols(importAdder, importableReference.symbols);
|
||||
typeNode = importableReference.typeNode;
|
||||
}
|
||||
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
||||
if (importableReference) {
|
||||
importSymbols(importAdder, importableReference.symbols);
|
||||
typeNode = importableReference.typeNode;
|
||||
}
|
||||
|
||||
// Ensure nodes are fresh so they can have different positions when going through formatting.
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @isolatedDeclarations: true
|
||||
// @declaration: true
|
||||
|
||||
// @Filename: /person-code.ts
|
||||
////export interface Person { x: string; }
|
||||
////export function getPerson() : Person {
|
||||
//// return null!
|
||||
////}
|
||||
|
||||
// @Filename: /code.ts
|
||||
////import { getPerson } from "./person-code";
|
||||
////export function wrapPerson() {
|
||||
//// return { person: getPerson() }
|
||||
////};
|
||||
|
||||
goTo.file("/code.ts");
|
||||
|
||||
verify.codeFix({
|
||||
description: "Add return type '{ person: Person; }'",
|
||||
index: 0,
|
||||
newFileContent:
|
||||
`import { getPerson, Person } from "./person-code";
|
||||
export function wrapPerson(): {
|
||||
person: Person;
|
||||
} {
|
||||
return { person: getPerson() }
|
||||
};`
|
||||
});
|
Загрузка…
Ссылка в новой задаче