-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
🔎 Search Terms
quickfix missing properties imports
🕗 Version & Regression Information
The quickfix was added in #44576 (cc @a-tarasyuk @komyg) but it doesn't appear to add missing imports.
💻 Code
// foo.ts
import { Bar } from "./bar";
const bar: Bar = {};
// bar.ts
export type SomeType = { x: string };
export interface Bar {
bar(): SomeType;
}🙁 Actual behavior
The "Add missing properties" quickfix generates the following:
import { Bar } from "./bar";
const bar: Bar = {
bar: function (): SomeType { // <-- Cannot find name 'SomeType'
throw new Error("Function not implemented.");
}
};🙂 Expected behavior
import { Bar, SomeType } from "./bar"; // <-- SomeType should be imported
const bar: Bar = {
bar: function (): SomeType {
throw new Error("Function not implemented.");
}
};Note that this works correctly for classes:
Before quickfix:
import { Bar } from "./bar";
class BarClass implements Bar {};After "Implement interface Bar" quickfix:
import { Bar, SomeType } from "./bar"; // <-- correctly added
class BarClass implements Bar {
bar(): SomeType {
throw new Error("Method not implemented.");
}
};Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Effort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this