Skip to content

Quick fix all for "Ignore this error message" can insert duplicate @ts-ignore comments if errors are on the same line #21378

@mjbvz

Description

@mjbvz

TypeScript Version: 2.7.0-dev.2018123

Search Terms:

  • Quick fix all
  • JavaScript
  • Ts-ignore

Code
Create a js file with two errors on the same line:

// @ts-check

const a = 1;
const b = 2;

a = 1; b = 1;

Trigger quick fix all to add // @ts-ignore before this line

Expected behavior:
Returned edit inserts a single // @ts-ignore

Actual behavior:

getCombinedCodeFix returns two duplicate insertions for // @ts-ignore. This results in:

// @ts-check

const a = 1;
const b = 2;

// @ts-ignore
// @ts-ignore
a = 1; b = 1;
[Trace  - 15:40:36] Response received: getCombinedCodeFix (2112). Request took 1 ms. Success: true 
Result: {
    "changes": [
        {
            "fileName": "/Users/matb/projects/san/b.js",
            "textChanges": [
                {
                    "start": {
                        "line": 6,
                        "offset": 1
                    },
                    "end": {
                        "line": 6,
                        "offset": 1
                    },
                    "newText": "// @ts-ignore\n"
                },
                {
                    "start": {
                        "line": 6,
                        "offset": 1
                    },
                    "end": {
                        "line": 6,
                        "offset": 1
                    },
                    "newText": "// @ts-ignore\n"
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions