microsoft / microsoft/TypeScript

Provide way to configure default compiler options for TS Server Inferred Project

Đang mở
#39,689 3 bình luận 8 reaction 0 người được giao Xem trên GitHub

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

In Discussion Suggestion
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ả

Search Terms

Inferred Project
TS Server

Suggestion

Add an option to configure the default compilerOptions for inferred projects outside of the host.

Related to: https://docs.google.com/document/d/1eB6cGCG_2ircfS5GzpDC9dBgikeYYcMxghVH5sDESHw/edit#heading=h.telvo0tzo7t0 and https://github.com/microsoft/TypeScript/issues/39632

Checklist

Use Cases

Currently, there is no way to configure the default compilerOptions for inferred projects outside of the server host. Being able to configure should options would be give a better DX when not using the default compiler options such as experimentalDecorators, strictNullChecks etc... together with stricter file inclusions, ie favoring explicitly listing the entry-point files using files instead of include with globbing.

Previously when not using TypeScript solution style tsconfig this could be achieved by adding a tsconfig.json in the root of the project which will include all files and set these options example.

{
   "compilerOptions":  {
     "experimentalDecorators": true,
     "strictNullChecks": true,
     ...
   }
}

This trickery cannot be used when using a solution style tsconfig, because the root tsconfig will not contain any files due to files: [] setting.

Examples

Ideally, compiler options for inferred projects are configured in a TypeScript configuration file. When using solution style tsconfig, such configuration can be set here.

{
 "files": [],
 "compilerOptions":  {
   "experimentalDecorators": true,
   "strictNullChecks": true,
   ...
 },
 "references": [
   {
     "path": "./tsconfig.app.json"
   },
   {
     "path": "./tsconfig.spec.json"
   }
 ]
}

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

//cc @kyliau

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 với hành vi inferred projects của TS Server và issue 39632 được liên kết, sau đó xem xét cách các tệp tsconfig theo kiểu solution-style có files: [] được xử lý. Xác định vị trí và thứ tự ưu tiên của cấu hình cần thiết cho các giá trị mặc định trong compilerOptions như experimentalDecorators và strictNullChecks. Hoàn thành khi inferred projects có thể nhận các giá trị mặc định đó mà không thay đổi hành vi của các project 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
tooling
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
Khá rõ ràng
Mức phù hợp với người mới
35/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.