microsoft / microsoft/TypeScript

Export an interface for JSON `CompilerOptions`

オープン
#30,897 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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 tsconfig without either requiring the user to import TypeScript enums or rewriting the interface.
  • The convertCompilerOptionsFromJson function takes in any currently, 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

lib/typescript.d.ts にリンクされている公開 CompilerOptions 宣言と、src/compiler/commandLineParser.ts のエントリポイント convertCompilerOptionsFromJson から始めます。JSON 形式のオプションインターフェイスを定義して公開し、その後、変換関数がそれを受け入れ、要求された型チェックの動作を維持することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
api, compilers
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。