Typescript - inlay hints for nested labeled tuples

未关闭
#57,088 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
typescript

调研方向

从 issue 中嵌套的带标签元组示例开始,在启用所有内嵌提示的情况下在 VS Code 中复现它。将嵌套数组调用与可正常工作的 rest-parameter 调用进行比较,然后跟踪负责元组标签的 TypeScript 内嵌提示入口点。完成的标准是嵌套的 minVals 和 maxVals 标签出现在预期位置,且不会导致现有示例回归。

由索引模型根据 Issue 内容生成。

描述

Bug Domain: LS: Inlay Hints Help Wanted

Type: Feature Request

The inlay hints for an array of labeled tuples are forgotten.

Troubleshooting steps:

  • Ensured Typescript is fully up-to-date.
  • Enabled all inlay hints in vsCode settings.

When a type is described as tuple with labels, you can use the ...args: ThatTupleType and when calling the function, the parameters retain the labels. This is working just fine.

However, when the argument is more complex, and there are nested labeled tuples within the type, the inlay hint information is lost (although the type information is still there; TypeScript still knows that the labels are on the array).

The expectation is that if I pass an array of tuples to an argument or type that expects the tuples to adhere to rules, and the type has labels, that the inlay hints should show those nested labels in the appropriate place.

The below example will showcase the issue I'm referring to, when it's run in vsCode with all inlay hints enabled:

type ArmorValueSet = [number, number, number, number, number, number];
type ArmorValueRange = [minVals: ArmorValueSet, maxVals: ArmorValueSet];

const parseArmor = (
    armorValues: ArmorValueRange[]
) => {
    console.log(armorValues);
};

parseArmor([
    [[6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]],
    [[6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]],
    [[6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]],
    [[6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]],
    [[6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]],
]);

const test = (...args: ArmorValueRange) => {
    console.log(...args);
}

test([6, 21, 36, 56, 81, 140], [20, 35, 55, 80, 110, 180]);

On line 22, minVals and maxVals are shown correctly. However, from lines 11-15, there are no inlay hints for these tuple labels. The expectation is that each of these lines should look the same as line 22 in terms of the inlay hints that are shown.

Here is a screenshot of what my vsCode editor looks like with this code present:

image

VS Code version: Code 1.85.1 (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.19045
Modes:

主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 19 小时
30 天内合并 PR
117

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。