microsoft / microsoft/TypeScript
Export an interface for JSON `CompilerOptions`
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
- CompilerOptions
- convertCompilerOptionsFromJson
Suggestion
Currently TypeScript exports the CompilerOptions interface, which represents the compiler options that can be passed in. However, since this interface uses enums, it doesn't match with the format of compilerOptions in the tsconfig.json file. I'd like to be able to use a JsonCompilerOptions (or some better name) interface to strictly type options in libraries that wrap TypeScript without rewriting the interface.
Use Cases
- Libraries that wrap TypeScript like rollup-plugin-typescript can strictly type overrides for values in
tsconfigwithout either requiring the user to import TypeScript enums or rewriting the interface. - The
convertCompilerOptionsFromJsonfunction takes inanycurrently, and could instead use this hypothetical interface.
Examples
TypeScript wrapping libraries can let consumers override tsconfig options
import { Plugin } from 'rollup';
import { JsonCompilerOptions } from 'typescript';
interface Options extends JsonCompilerOptions {
customOptions?: string;
}
export default function rollupPluginTypescript(options?: Options): Plugin;
Strict typing for convertCompilerOptionsFromJson
import { convertCompilerOptionsFromJson } from 'typescript';
// Type error
const opts = convertCompilerOptionsFromJson({ allowJs: 'true' }, process.cwd());
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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 với khai báo công khai CompilerOptions được liên kết trong lib/typescript.d.ts và entry point convertCompilerOptionsFromJson trong src/compiler/commandLineParser.ts. Định nghĩa interface tùy chọn có dạng JSON và expose nó công khai, sau đó đảm bảo hàm chuyển đổi chấp nhận nó mà vẫn giữ nguyên hành vi kiểm tra kiểu được yêu cầu.
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
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100