Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Missing properties quickfix does not add missing imports聽#49001

Copy link
Copy link

Description

@hpx7
Issue body actions

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.");
  }
};
Reactions are currently unavailable

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.