Skip to content

Unused declaration behavior differs from tsserver #2001

@jakebailey

Description

@jakebailey

Given this code:

function unused() {}

In tsserver without noUnusedLocals, this is grayed out:

Image

With noUnusedLocals, it's grayed out and also gets a warning squiggle:

Image

But, with tsgo's LSP implementation, these differ.

Without noUnusedLocals, there are no diagnostics at all, no graying:

Image
[Trace - 10:37:58 PM] Received response 'textDocument/diagnostic - (14)' in 4ms.
Result: {
    "kind": "full",
    "items": []
}

With noUnusedLocals, it gets an error-level squiggle:

Image
[Trace - 10:37:16 PM] Received response 'textDocument/diagnostic - (13)' in 8ms.
Result: {
    "kind": "full",
    "items": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 9
                },
                "end": {
                    "line": 0,
                    "character": 15
                }
            },
            "severity": 1,
            "code": 6133,
            "source": "ts",
            "message": "'unused' is declared but its value is never read."
        }
    ]
}

We are clearly missing diagnostics and the correct info on diagnostics when we have them.

Metadata

Metadata

Assignees

Labels

Domain: EditorRelated to the LSP server, editor experiencebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions