Better handling for manually created source files and compiler APIs

Đang mở
#28,413 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi crash với ts.createSourceFile và một truy vấn tới trình kiểm tra kiểu của chương trình trên một nút trong tệp được tạo thủ công. Xem lại các issue được liên kết và xác định xem hành vi này nên không được hỗ trợ, thất bại một cách tường minh hay được hỗ trợ động. Được xem là hoàn tất khi hành vi API đã được quyết định và có phần triển khai cùng việc xác thực tương ứng.

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

Mô tả

Domain: API Needs Proposal Suggestion

Search Terms

type checker source file cannot ready property 'members' of undefined

Suggestion

When a user of the compiler API manually creates a source file with ts.createSourceFile instead of retrieving it from their program, and then asks the program for type inference on a contained node, this can crash. See https://github.com/Microsoft/TypeScript/issues/8136 / https://github.com/vuejs/vue-cli/issues/2712 / https://github.com/angular/tsickle/issues/151 / https://github.com/general-language-syntax/TS-GLS/issues/39.

It seems like one of three interpretations might be best:

  • This is explicitly unsupported behavior, but for the sake of performance & simplicity, no checks should happen
  • This is explicitly unsupported behavior, and a more explicit error should be thrown
  • This should become supported behavior, and the program should dynamically create source files as requested

Use Cases

Auto-generated TypeScript files, such as .vue snippets, still want access to a type checker, such as for TSLint rules.

Examples

https://github.com/palantir/tslint/issues/4273

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
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

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.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

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.