microsoft / microsoft/TypeScript
API: make 'isExternalOrCommonJsModule' public
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ả
Suggestion
🔍 Search Terms
isExternalOrCommonJsModule, commonJsModuleIndicator
✅ Viability 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
Make the existing utility function ts.isExternalOrCommonJsModule public by moving it from utilities.ts to utilitiesPublic.ts
📃 Motivating Example
TypeScript treats commonJS modules similar to external modules. But currently there's no way for an API user to know whether TypeScript considers a file as commonJS module. SourceFile#commonJsModuleIndicator is not exposed in the public API and there's no ts.isCommonJsModule as pendant to ts.isExternalModule.
💻 Use Cases
My current use case is to determine whether a file (or top-level declaration inside of it) contributes to the global scope. Currently I can only handle external modules, which doesn't match what TypeScript does internally.
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ắt đầu bằng cách đọc isExternalOrCommonJsModule trong utilities.ts và các export công khai trong utilitiesPublic.ts. Kiểm tra cách các utility công khai liên quan như isExternalModule được expose và chạy các bài kiểm thử Compiler API liên quan; được xem là hoàn tất khi utility này có thể được sử dụng công khai mà không thay đổi hành vi runtime hiện có.
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
- api, compilers
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100