microsoft / microsoft/TypeScript

Bloomberg feedback for 5.9

Đang mở
#62,156 1 bình luận 7 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Discussion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 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](https://github.com/microsoft/TypeScript/issues/62153) |
| 2 | `Promise.all` over constant tuples no longer infers tuple | Type Checking | No | <1% | [#62071](https://github.com/microsoft/TypeScript/issues/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:

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

Produces invalid declaration output:

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

5.8 output was also incorrect but at least syntactically valid:

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

❗This seems like a major regression, since emitted declarations are now invalid.
Tracked in [#62153](https://github.com/microsoft/TypeScript/issues/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:

```ts
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](https://github.com/microsoft/TypeScript/issues/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.

```ts
(test ?? true) ? A : B
```

Becomes:

```ts
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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các đoạn mã tái hiện trong issue và các ticket được liên kết #62153 và #62071, trong đó theo dõi hai trong số các hồi quy đã được báo cáo. So sánh hành vi khai báo hoặc type-checking của 5.8 và 5.9, sau đó giới hạn mọi công việc vào một hồi quy đã được xác nhận; bản báo cáo tự nó không xác định các tệp, bài kiểm thử hoặc một Definition of done duy nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
15/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.