microsoft / microsoft/TypeScript

Bloomberg TS5.5-beta feedback [part two]

Đang mở
#58,587 1 bình luận 9 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.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

Acknowledgement
  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment

I was delayed starting my half of Bloomberg's TypeScript beta analysis. Part one here: https://github.com/microsoft/TypeScript/issues/58523


We are in the process of evaluating the impact of TS 5.5 beta on Bloomberg code. Below are preliminary findings.

Overall this looks to be a very positive release.

Change Affects Release notes Packages affected
Cleaner .d.ts emit Declaration Yes Over 20%
Inferred type predicates Type Checking Yes 4
Control flow narrowing for constant indexed access Type Checking Yes 1
Stricter module interpretation Type Checking & Emit Yes 8
noCheck builds

Cleaner `.d.ts` emit

https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#isolated-declarations

Over 10% of our packages stopped erroring compared to using TypeScript 5.4 due to now emitting .d.ts that pass our post-build declaration validation steps; a primary check is that the .d.ts are only using valid imports. This is most likely due to the reduction of inferred dynamic type imports and instead using imports from the original source:

+ import type { Foo } from "./local-file";
- export declare const thing: (arg: Utility<import("../path/to/something").Value>) => void;
+ export declare const thing: (arg: Foo) => void;

We also noticed cases where jsdoc started to be preserved in the .d.ts emit, which was great.


 declare const Vec3d: {
     create: {
+        /**
+         * Useful documentation here
+         */
         (): Vec3d;
     }

Inferred type predicates

https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#inferred-type-predicates

Four packages started to error due to inferred type predicates. The code changes required to fix these errors were straight forward.

Control flow narrowing for constant indexed access

https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#control-flow-narrowing-for-constant-indexed-accesses

Only one package started to error due to this change. The code changes required to fix the error was straight forward.

Stricter module interpretation

We've had a mixture of issues here. For context on the projects we saw errors: while there is a package.json in a parent directory, usually above the tsconfig.json directory, this is not for the TypeScript project. The package.json is there for the repo-wide tooling (e.g. eslint). The TypeScript project within the repo is not a Node package.

For the teams that have specified "type": "module" in this package.json we started to get build errors for projects that were relying on some of the previously allowed CJS compatibility.

Two projects were using export = in a .d.ts file and started to get:

error TS1203: Export assignment cannot be used when targeting ECMAScript modules

Four projects were incorrectly using the synthetic default export:

error TS1192: Module has no default export.

One project had "type": "commonjs" in their package.json which meant that it started to emit CJS, even though the tsconfig.json 'target' was set to esnext. To fix this we will likely need to update the repo to remove the "type": "commonjs".

`noCheck` builds

While not publicly exposed I used a locally patched version of typescript.js to analyze the potential impact of noCheck: false on ts.transpileModule and #50699.
The results were very promising, a 4 second build dropped down to 2.2 seconds.

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 bằng việc đọc các phát hiện trong issue này, các ghi chú phát hành beta TypeScript 5.5 được liên kết và issue #50699. Điểm vào triển khai duy nhất được đề cập là ts.transpileModule, được đánh giá bằng một typescript.js đã được patch cục bộ. Done không được định nghĩa vì báo cáo không yêu cầu thay đổi mã cụ thể hoặc bài kiểm thử chấp nhận nào.

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
Tính năng
Độ 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
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.