Skip to content

'module.exports' suggestion diagnostic: only show on 'module.exports' itself #23272

Closed
@mjbvz

Description

@mjbvz

TypeScript Version: 2.9.0-dev.20180409

Search Terms:

  • suggestion
  • diagnostic / diagnostics

Code
For the js:

module.exports = function() {
    console.log('hello world')
}

Problem
The Convert to ES6 module suggestion covers the entire function:

[Trace  - 10:21:34 AM] Event received: suggestionDiag (0).
Data: {
    "file": "/Users/matb/Downloads/k388w8mmpo/src/button.js",
    "diagnostics": [
        {
            "start": {
                "line": 1,
                "offset": 1
            },
            "end": {
                "line": 3,
                "offset": 2
            },
            "text": "File is a CommonJS module; it may be converted to an ES6 module.",
            "code": 80001,
            "category": "suggestion"
        }
    ]
}

This means that we show a lightbulb when you are anywhere inside the exported function.

Instead I believe that the suggestion range should only cover the module.exports part

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions