Skip to content

Clickable inlay hints don't work correctly across files #55474

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
// @filename: tsconfig.json
{
    "compilerOptions": {
        "target": "esnext",
        "module": "nodenext"
    },
    "include": ["src/**/*"]
}
// @filename: aaa.mts

import { helperB } from "./bbb.mjs";

helperB("hello, world!");

// @filename: bbb.mts
import { helperC } from "./ccc.mjs";

export function helperB(bParam: string) {
    helperC(bParam);
}

// @filename: ccc.mts
export function helperC(cParam: string) {
}

In aaa.ts, the argument to helperB is value. If you click on it, nothing happens. If you look at the TSServer trace, you'll notice that it directs to aaa.ts

[trace] <semantic> Response received: provideInlayHints (341). Request took 1 ms. Success: true  [
    {
        "text": "",
        "position": {
            "line": 3,
            "offset": 9
        },
        "kind": "Parameter",
        "whitespaceAfter": true,
        "displayParts": [
            {
                "text": "bParam",
                "span": {
                    "start": {
                        "line": 3,
                        "offset": 25
                    },
                    "end": {
                        "line": 3,
                        "offset": 28
                    },
                    "file": "USERDIR/scratch/example/src/aaa.mts"
                }
            },
            {
                "text": ":"
            }
        ]
    }
]

Also notice that the offset difference of 25 and 28 doesn't correspond to anything meaningful.

On the other hand, in bbb.mts, the inlay hint for cValue seems to jump be to ccc.mts; however, I don't quite understand how or why. There's no data in the response that indicates it should jump to ccc.mts.

[
    {
        "text": "",
        "position": {
            "line": 4,
            "offset": 14
        },
        "kind": "Parameter",
        "whitespaceAfter": true,
        "displayParts": [
            {
                "text": "cParam",
                "span": {
                    "start": {
                        "line": 1,
                        "offset": 25
                    },
                    "end": {
                        "line": 1,
                        "offset": 31
                    },
                    "file": "c:/Users/drosen/scratch/example/src/bbb.mts"
                }
            },
            {
                "text": ":"
            }
        ]
    }
]

One more thing - if you modify ccc.mts to something like

// hi :)

export function helperC(cValue: string) {

}

you'll get a nonsensical response for the line/column:

[
    {
        "text": "",
        "position": {
            "line": 4,
            "offset": 14
        },
        "kind": "Parameter",
        "whitespaceAfter": true,
        "displayParts": [
            {
                "text": "cValue",
                "span": {
                    "start": {
                        "line": 3,
                        "offset": 1
                    },
                    "end": {
                        "line": 3,
                        "offset": 3
                    },
                    "file": "c:/Users/drosen/scratch/example/src/bbb.mts"
                }
            },
            {
                "text": ":"
            }
        ]
    }
]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions