Skip to content

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

Closed
@mjbvz

Description

@mjbvz

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"
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions