microsoft / microsoft/TypeScript
5.8.3 - Big repo with complex types in Angular - Maximum call stack size exceeded
Chưa có ai nhận issue này.
- 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ả
🔎 Search Terms
max call stack size
🕗 Version & Regression Information
- I was unable to test this on prior versions because of custom code on our end
⏯ Playground Link
No response
💻 Code
We use a custom version of TypeScript, here are our changes, all the changes are similar, we just changed the values and the version of TS to publish it on our Azure DevOps
src/compiler/checker.ts
...
19126 if (tailCount === 5e4) {
...
20365 if (instantiationDepth === 5e3 || instantiationCount >= 5e8) {
...
lib/_tsc.js
...
61663 if (tailCount === 5e4) {
...
62704 if (instantiationDepth === 5e3 || instantiationCount >= 5e8) {
...
lib/typescript.js
...
66273 if (tailCount === 5e4) {
...
67314 if (instantiationDepth === 5e3 || instantiationCount >= 5e8) {
...
As for our repository I could share it somewhere under some NDA because the error depends probably on the size and the complexity of the types.
🙁 Actual behavior
RangeError: Maximum call stack size exceeded
at ...\node_modules\typescript\lib\typescript.js:72137:242
at map (...\node_modules\typescript\lib\typescript.js:2491:19)
at inferTypesFromTemplateLiteralType (...\node_modules\typescript\lib\typescript.js:72137:224)
at inferToTemplateLiteralType (...\node_modules\typescript\lib\typescript.js:72590:23)
at inferFromTypes (...\node_modules\typescript\lib\typescript.js:72364:9)
at inferTypes (...\node_modules\typescript\lib\typescript.js:72209:5)
at structuredTypeRelatedToWorker (...\node_modules\typescript\lib\typescript.js:69945:13)
at structuredTypeRelatedTo (...\node_modules\typescript\lib\typescript.js:69474:21)
at recursiveTypeRelatedTo (...\node_modules\typescript\lib\typescript.js:69425:19)
at isRelatedTo (...\node_modules\typescript\lib\typescript.js:68843:122)
🙂 Expected behavior
All this used to work with 5.4.5 but it does not with 5.8.3
Additional information about the issue
We always had problems with complex types in TypeScript in our project which is pretty big (which also makes us question if it is really suited for bigger projects...).
We have experienced a lot of Type instantiation is excessively deep and possibly infinite errors and it's not clear which types cause them or how to solve the issue.
So we resolved to "hacking" TypeScript by using a custom version of 5.4.5 where we bumped up the values of tailCount, instantiationDepth and instantiationCount to fit our needs and everything was working with Angular 17 and 18, when we tried upgrading to Angular 19 with TypeScript 5.8.3 "hacked" we get the Error above.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Báo cáo chỉ đến src/compiler/checker.ts và các tệp được tạo lib/typescript.js và lib/_tsc.js, với stack đi vào inferTypesFromTemplateLiteralType và các hàm suy luận liên quan. Trước tiên, hãy rút gọn trường hợp từ repository Angular riêng tư thành một bản tái hiện công khai và so sánh TypeScript 5.4.5 với 5.8.3. Được xem là hoàn tất khi bản tái hiện không còn gây ra lỗi độ sâu call stack tối đa mà vẫn giữ nguyên hành vi kiểm tra kiểu dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, 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