microsoft / microsoft/TypeScript

Bloomberg feedback for 5.9

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

还没有人认领这个 Issue。

Discussion
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

Comment

We evaluated the 5.9 RC releases and 5.9 is a low impact release for us.

# Change Affects Release notes Packages affected PR / Issue
1 Class expressions with private fields produce invalid .d.ts output Declaration Emit No <1% #62153
2 Promise.all over constant tuples no longer infers tuple Type Checking No <1% #62071
3 JavaScript emit removes parentheses around ?? in conditional expressions Emit No <1%
4 Better detection of always-true errors in ?? expressions Type Checking No <1%

Class expressions with private fields produce invalid .d.ts output

With TypeScript 5.9, the following code:

export const ClassExpression = class {
    #context = 0
};

Produces invalid declaration output:

export declare const ClassExpression: {
    new (): {
        #context: number;
    };
};

5.8 output was also incorrect but at least syntactically valid:

export declare const ClassExpression: {
    new (): {
        "__#1@#context": number;
    };
};

❗This seems like a major regression, since emitted declarations are now invalid.
Tracked in #62153

Promise.all over array literal no longer infers a tuple

This issue is easier to reproduce than the linked ticket may suggest. It affects any use of Promise.all in the return position of a .then() that chains from a promise resolving to an array:

const p = Promise.resolve([]).then(() => {
    return Promise.all([0, ""]);
});
const test: Promise<[number, string]> = p; // error

This now fails to infer a tuple and infers Promise<(string | number)[]> instead.
While we can work around this issue by assigning the result of Promise.all to an intermediate variable, this does seem like an unfortunate regression.

Tracked in #62071

JavaScript emit removes parentheses around ?? in conditional expressions

In some cases, parentheses are removed from nullish coalescing expressions in emitted JavaScript. This change seems benign.

(test ?? true) ? A : B

Becomes:

test ?? true ? A : B

Better detection of always-true errors in ?? expressions

We observed two new diagnostics related to always-true ?? expressions.
The improved detection highlighted logic errors that were previously missed.

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 issue 中的复现代码片段以及链接的 ticket #62153 和 #62071 开始,这两个 ticket 跟踪了报告中的两个回归问题。比较 5.8 和 5.9 的声明或 type-checking 行为,然后将工作范围限定为一个已确认的回归问题;报告本身没有确定文件、测试或单一的 Definition of done。

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

评估

技术栈
javascript, typescript
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
15/100

把新 issue 发到你的邮箱

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