microsoft / microsoft/TypeScript

Google feedback on TS 5.8-beta

Đang mở
#61,116 1 bình luận 4 reaction 0 người được giao Xem trên GitHub
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ả

### Acknowledgement

- [x] I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

### Comment

This GitHub issue contains feedback on the TS 5.8-beta release from the team that is responsible for keeping Google's internal software working with the latest version of TypeScript.

## Executive summary

* We do not expect to have significant difficulty in upgrading Google to TS 5.8.
* Some changes to our TypeScript code are required to fix compilation.
* Most of the new errors are clearly related to announced changes.
* Detail sections below explain the changes we expect to make to unblock the upgrade.

## Impact summary

| Change description | Announced | Libraries affected |
| -------------------------------------- | --------: | -----------------: |
| Conditional expression checking | Yes | ~0.007% |
| lib.d.ts Changes | Yes | ~0.005% |

The **Announced** column indicates whether we were able to connect the observed change with a section in the [TS5.8-beta announcement].

[TS5.8-beta announcement]: https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/

The following sections give more detailed explanations of the changes listed above.

## Announced Changes

This section reviews all announced changes from the [TS5.8-beta announcement], whether we support these changes at Google, how we will resolve pre-existing issues for these changes (if applicable), and other thoughts.

### Checked Returns for Conditional and Indexed Access Types

We support this change. It improves ergonomics and type checking accuracy and uncovers real unintentional runtime behavior.

The [PR](https://github.com/microsoft/TypeScript/pull/56941) mentions a breaking change to conditional expression checking, which might be worth calling out explicitly in the release notes. We found that this caused errors in ~0.007% of our libraries, generally due to one branch being typed as `any`, causing the other branch to now be checked.

Most of the errors caused this way were legitimate, though some were arguably spurious (e.g. this uncovered [an instance][2] of #17002), while a few sat somewhere [in between][1]. We will work through most of these by just suppressing the error with `// @ts-ignore` and a note advising owners to revisit their code and fix the underlying problems.

[1]: https://www.typescriptlang.org/play/?ts=5.8.0-beta#code/PTAEDkHkBUFEC5QDsCGBLAbgUwDYE9QB7JLUAd0IFccATUFAZwcoFtSAXACxXdAAMUAJwDmoNEgbsUSAMZZCAM1AARHlj6g20hqC48AUCFDRQAXhVqAdKGOc0OxsxYAHdmmJidlZihz5QzoJY7OwEDCgKWAA0oABGlLxovDSEWDqSaH6GYBjuOGqgADL2ANaEGKDMsRnsCe5IMeK63LxkpDJUtKA0WAripCiVlLEy+UxECtkW7ANIdDK+OPyjxFgAPADKw6ozAHwaZHYynOSddJQSEbgEQbWCSPTTWFPiklgodIqPW7E7WJb6BQXGRuDwrEhraC7AAUQmEiGgAEoEaAAN76Gy3Sj3egiMQSKSyeRKP6gAD8yCwZCesJEiNAiFpokY9CQeERAG59ABfIA
[2]: https://www.typescriptlang.org/play/?ts=5.8.0-beta#code/GYVwdgxgLglg9mABFOBBATughgTwBQAeAXIgM5ToxgDmAPugKZYAmCANjmRVdQNoC6AShKMW7TuUo0BiAN4AoRIkZQQ6JBmw4AdDFKbchQYgD8iAohK8C-ANzyAvvKA

These were essentially all instances of TS2322.

### The --erasableSyntaxOnly Option

We support this change, though we will not be able to take advantage of it any time soon. In particular, we're interested in seeing something like #60790, which actually aligns quite well with the Closure-style enums that are very common in our codebase.

### Preserved Computed Property Names in Declaration Files

We support this change, and will leverage it immediately to better handle symbol properties under isolated declarations.

### lib.d.ts changes

We support these changes.

The changed declarations cause a few problems we will need to work around. In particular, the change to the `Window.location` setter broke ~0.004% of our targets, primarily tests mocking out the `Location` object with a `FakeLocation`. We will silence these with `// @ts-ignore`. Additionally, a handful of new declarations conflict with older versions in DefinitelyTyped and we'll need to adjust these dependencies.

### Other changes

The following changes are largely irrelevant in our codebase and we don't have anything to add about them:

* Support for require() of ECMAScript Modules in --module nodenext
* --module node18
* The --libReplacement Flag
* Optimizations on Program Loads and Updates
* Restrictions on Import Assertions Under --module nodenext

## Unannounced Changes

As mentioned above, the change in type checking of conditional expressions is a notable breaking change. While it was technically announced via details in the PR linked in the announcement, it's easy to miss and could stand to be called out more explicitly.

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

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

Hướng nghiên cứu

Bắt đầu với thông báo về TS 5.8-beta và PR #56941 được liên kết, sau đó xem xét các thay đổi đối với biểu thức điều kiện và lib.d.ts được mô tả ở đây. Issue cung cấp phản hồi từ hệ sinh thái thay vì nêu tên một tệp, một bài kiểm thử hoặc một thay đổi cụ thể, nên không có mục tiêu hoàn thành được xác định ngoài việc xác định xem tài liệu release hoặc hành vi của compiler có cần được theo dõi tiếp hay không.

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

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
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
20/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.