microsoft / microsoft/TypeScript
Having a `pedantic` option in TSConfig in addtion to `strict`
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
🔍 Search Terms
"tsconfig pedantic" "tsconfig setting" "tsconfig noimplicitreturn" "tsconfig noimplicitreturn pedantic"
✅ Viability Checklist
- 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 our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
It would be nice to have a pedantic option in tsconfig.json, along the lines of strict, but basically turning on everything.
I currently have the following, for instance:
"strict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
This turns on all checks listed in the documentation, but it was a bit of a slog to figure out which options weren't covered by the first line ("strict": true). Also, if new Type Checking settings were introduced, I would have to figure that out and add them manually.
I would propose a simple option pedantic, which sets all of the options to their most strict option. Basically replacing the whole list above with a single line of "pedantic": true. When new settings are added, they would automatically be covered by this.
📃 Motivating Example
If strict is good, pedantic should be better. Not everybody can use it in all situations, but these settings exist for a reason, and this would be the easiest way to turn them all on.
Of course individual settings can still be overridden, in case specific code needs that. But programmers striving to write TypeScript as clean as possible will be able to have the compiler help them as much as possible with this.
All of the Type Checking settings exist for good reasons, let's make it easy for people to use them all.
💻 Use Cases
-
What do you want to use this for?
Learning to write the cleanest of TypeScript code. -
What shortcomings exist with current approaches?
Having to manually scour the documentation/changelog for TypeScript to find out what Type Checking settings aren't covered bystrict -
What workarounds are you using in the meantime?
See the previous point
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提案では tsconfig.json と既存の strict および type-checking オプションが挙げられていますが、実装ファイルやテストについては触れられていません。まず、コンパイラーオプションがどのように分類され、ドキュメント化されているかを追跡し、次に pedantic に含める設定と個別の上書きの動作を定義してください。完了の条件は、このオプションが意図したチェックを一貫して有効にし、テストとドキュメントでカバーされていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100