microsoft / microsoft/TypeScript
Having a `pedantic` option in TSConfig in addtion to `strict`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Vorschlag nennt tsconfig.json sowie die vorhandenen Optionen strict und type-checking, aber keine Implementierungsdateien oder Tests. Beginne damit nachzuverfolgen, wie Compileroptionen gruppiert und dokumentiert werden, und lege dann fest, welche Einstellungen pedantic umfasst und wie sich individuelle Überschreibungen verhalten; abgeschlossen ist die Arbeit, wenn die Option die beabsichtigten Prüfungen konsistent aktiviert und durch Tests und Dokumentation abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100