Skip to content

Missing properties quickfix does not add missing imports #49001

Closed

Description

@hpx7

Bug Report

🔎 Search Terms

quickfix missing properties imports

🕗 Version & Regression Information

The quickfix was added in #44576 (cc Oleksandr Tarasiuk (@a-tarasyuk) Felipe Armoni (@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.");
  }
};

Activity

  1. added
    Bug
    Domain: LS: Quick Fixes
    Effort: Casual
    on May 6, 2022
  2. added
    Fix Available
    on May 7, 2022
  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: LS: Quick FixesEffort: CasualFix Available

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions