-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Auto-importDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 3.9.0-dev.20200330
Search terms
- quick fix
- declare method
- import
Repro
For a project:
foo.ts
export interface Foo {
abc: number;
}
export function doFoo(callback: (x: Foo) => void) { }index.ts
import { doFoo } from "./foo";
class Bar {
bar() {
doFoo(x => this.baz(x))
}
}- Trigger the
declare methodquick fix onbaz
Expected behavior:
An import for Foo is added to the top of the file:
import { doFoo, Foo } from "./foo";
class Bar {
bar() {
doFoo(x => this.baz(x))
}
baz(x: Foo): void {
throw new Error("Method not implemented.");
}
}Actual behavior:
An inline import is added:
import { doFoo } from "./foo";
class Bar {
bar() {
doFoo(x => this.baz(x))
}
baz(x: import("./foo").Foo): void {
throw new Error("Method not implemented.");
}
}Playground Link:
Related Issues:
bpasero
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Auto-importDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this