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

"Add all missing imports" adds them all in one line #38082

Copy link
Copy link
@mjbvz

Description

@mjbvz
Issue body actions

TypeScript Version: 3.9.0-dev.20200420

Search Terms:

  • fix all
  • code action
  • quick fix

Code
With @types/node installed, open a file:

join();
homedir()
  1. Now trigger quick fixes and select add all missing imports

Bug:
The two imports are added on the same line:

import { join } from "path";import { homedir } from "os";

join();
homedir()

Here's the edit that TS Server returns in this case

[Trace  - 23:52:04.985] <semantic> Response received: getCombinedCodeFix (72). Request took 13 ms. Success: true 
Result: {
    "changes": [
        {
            "fileName": "/Users/matb/projects/san/test.ts",
            "textChanges": [
                {
                    "start": {
                        "line": 1,
                        "offset": 1
                    },
                    "end": {
                        "line": 1,
                        "offset": 1
                    },
                    "newText": "import { join } from \"path\";"
                },
                {
                    "start": {
                        "line": 1,
                        "offset": 1
                    },
                    "end": {
                        "line": 1,
                        "offset": 1
                    },
                    "newText": "import { homedir } from \"os\";\n"
                }
            ]
        }
    ]
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a 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.