Skip to content

Add missing this. quick fix can insert before leading comment #21433

@mattbierner

Description

@mattbierner

typescript@2.8.0-dev.20180126

Code

class Foo {
    private x: string = ''
    
    bar() {
        // comment
        x.toString()
    }
}

Trigger quick fix to add missing this. on x

Expected behavior:

class Foo {
    private x: string = ''
    
    bar() {
        // comment
        this.x.toString()
    }
}

Actual behavior:

class Foo {
    private x: string = ''
    
    a() {
        this.
            // comment
            x.toString()
    }
}
[Trace  - 20:24:49] Response received: getCodeFixes (72). Request took 2 ms. Success: true 
Result: [
    {
        "description": "Add 'this.' to unresolved variable",
        "changes": [
            {
                "fileName": "untitled:^Untitled-1",
                "textChanges": [
                    {
                        "start": {
                            "line": 5,
                            "offset": 1
                        },
                        "end": {
                            "line": 6,
                            "offset": 10
                        },
                        "newText": "        this.\n            // comment\n            x"
                    }
                ]
            }
        ],
        "fixId": "forgottenThisPropertyAccess"
    }
]

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: LS: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issue

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