Skip to content

Extract method refactoring incorrectly shown for import statement #17997

Closed
@mjbvz

Description

@mjbvz

TypeScript Version: 2.5.1
Code

import _ from 'lodash'

Place cursor at start of line.

Expected behavior:
No refactorings are provided

Actual behavior:
An extract method refactoring is provided:

[Trace  - 5:37:09 PM] Sending request: getApplicableRefactors (44). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/san2/bar.js",
    "startLine": 1,
    "startOffset": 1,
    "endLine": 1,
    "endOffset": 7
}
[Trace  - 5:37:09 PM] Response received: getApplicableRefactors (44). Request took 2 ms. Success: true 
Result: [
    {
        "name": "Extract Method",
        "description": "Extract function",
        "inlineable": true,
        "actions": [
            {
                "description": "Extract function into 'file '/Users/matb/projects/san2/bar.js''",
                "name": "scope_0"
            }
        ]
    }
]

Applying the refactoring results in:

newFunction() _ from 'lodash'
function newFunction() {
    return import ;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbolFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions