Skip to content

When implements interface in typescript adds import before element #28165

Closed

Description

@mjbvz

From Michal Diviš (@inferius) on October 11, 2018 8:6

Hi, implements interface in typescript auto adds import with absolute path before element of class.

  • VSCode Version: 1.28.0
  • OS Version: Windows 10

Steps to Reproduce:
ezgif-1-cab6cff57ba4

Does this issue occur when all extensions are disabled?: Yes

Copied from original issue: microsoft/vscode#60606

Activity

  1. mjbvz commented on Oct 26, 2018

    @mjbvz
    ContributorAuthor

    Please try upgrading your workspace to use typescript@next by following these instructions. Do you still see this error after upgrading?

  2. mjbvz commented on Oct 26, 2018

    @mjbvz
    ContributorAuthor

    From Michal Diviš (@inferius) on October 12, 2018 7:28

    Yes, i still see this error after upgrading.

  3. mjbvz commented on Oct 26, 2018

    @mjbvz
    ContributorAuthor

    Thanks for testing. Can you please share your tsconfig and a basic description of your project structure

  4. mjbvz commented on Oct 26, 2018

    @mjbvz
    ContributorAuthor

    From Danny Tuppeny (@DanTup) on October 23, 2018 9:3

    Matt Bierner (@mjbvz) I see this too. I've pushed a branch with a repro here:

    https://github.com/Dart-Code/Dart-Code/tree/vscode-60606-repro

    Clone the vscode-60606-repro branch, open src/pub/pub_task_provider.ts and then use the quick-fix to implement the interface. I changed it to typescript@latest and see the same issue.

    screen shot 2018-10-23 at 9 57 51 am

    screen shot 2018-10-23 at 9 57 56 am

    screen shot 2018-10-23 at 10 03 01 am

    (using * as vs in the import correctly puts vs. prefixes instead of import calls).

  5. removed their assignment
    on Oct 26, 2018
  6. 3 remaining items

  7. MeirionHughes commented on May 9, 2019

    @MeirionHughes

    Any update on this? just seems to have been kicked into the long grass.

  8. weswigham commented on May 9, 2019

    @weswigham
    Member

    We'd probably take PRs to fix it ❤️

  9. mjbates7 commented on Aug 22, 2019

    @mjbates7

    Still occurring - running insiders 1.38.0 build. Any updates or thoughts? It's generating code like this: (angular)

    image

  10. weswigham commented on Aug 23, 2019

    @weswigham
    Member

    That code is technically equivalent to the version where an import statement is used, just not as pretty - hence why this hasn't been the highest priority for us, and why I said we'd take a PR to fix it~ ❤️

  11. keotl commented on Aug 28, 2019

    @keotl

    I opened a PR which forces private aliases for implemented interface types. However, pointers would be appreciated for adding automatic importation.

    giphy

  12. weswigham commented on Aug 28, 2019

    @weswigham
    Member

    You'd want to query for the same type nodes that we do today (complete with import types), but then traverse the node tree looking for instances of ImportTypeNodes, and transform them into a normal type reference by replacing the import(...) part with a generated name, and then adding an import * as generatedName from "..." statement. Then you can get smarter, like using named imports rather than namespace, and merging with existing import statements where possible.

  13. keotl commented on Aug 30, 2019

    @keotl

    I pushed a new version with automatic imports.
    giphy
    This would be ready for review/testing.

  14. JulianLang commented on Nov 8, 2019

    @JulianLang

    So, what's the status here?

  15. avol-io commented on Mar 2, 2020

    @avol-io

    any news?

  16. andrewbranch commented on Mar 9, 2020

    @andrewbranch
    Member

    This was fixed by #36615 which is included in TypeScript 3.8.

    Unfortunately, #34995, the issue I was assigned, was never marked as a duplicate of this one, and so I was never aware of the existence of this issue or the great work by Kento Lauzon (@keotl) at #33126. Sadly this happens from time to time in a repo with thousands of issues, but my apologies for the mixup nonetheless, particularly to Kento Lauzon (@keotl).

  17. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions