microsoft / microsoft/TypeScript

`NoInfer` changes behavior for type matching on spread

未关闭
#63,627 5 条评论 0 个 reaction 已指派 1 人 已被 @ahejlsberg 认领 在 GitHub 查看
Needs Investigation
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

### 🔎 Search Terms

NoInfer spread

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, and I reviewed the FAQ for entries about `NoInfer`

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.3#code/GYVwdgxgLglg9mABAQwE6oIwApkC5EDaYIAtgEYCmqANIgHQMBycAkmMFQDwEC6AfDwCUiAN4BfAFBpMWAhiEBuCRNCRYCFOgBMOfEVKUa9BryGjJ0nXMXLV0eElXY8iLAA98xclVoM6cfGY2DlRufmEAXj5EADc4GAATYXEVcGw3RCjzQSVUtQdEVR0Xd08DH2N-PTMsuMTkySL3TOjxHIkgA

### 💻 Code

```ts
function arr1(a: [number, ...NoInfer<[]>]) {}
arr1([1]);

function arr2(a: [number, ...[]]) {}
arr2([1]);

function fun1(a: (x: number, ...o: NoInfer<[]>) => void) {}
fun1(x => {});

function fun2(a: (x: number, ...o: []) => void) {}
fun2(x => {});
```

### 🙁 Actual behavior

The two function calls to functions with `NoInfer` triggers type error, while the other two to equivalent function without `NoInfer` don't.

### 🙂 Expected behavior

This code should work without type error.

### Additional information about the issue

_No response_

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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