Closed
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.");
}
};