Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DanielRosenwasser opened this issue Aug 22, 2023 · 0 comments · Fixed by #55476
Closed

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

DanielRosenwasser opened this issue Aug 22, 2023 · 0 comments · Fixed by #55476
Assignees
Labels
Bug A bug in TypeScript Domain: Inlay Hints Fix Available A PR has been opened for this issue

Comments

@DanielRosenwasser
Copy link
Member

// @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": ":"
            }
        ]
    }
]
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.3.0 milestone Aug 22, 2023
@DanielRosenwasser DanielRosenwasser changed the title Clickable inlay hints doesn't Clickable inlay hints doesn't work correctly across files Aug 22, 2023
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Aug 23, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Aug 23, 2023
@DanielRosenwasser DanielRosenwasser changed the title Clickable inlay hints doesn't work correctly across files Clickable inlay hints don't work correctly across files Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Inlay Hints Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants