microsoft / microsoft/TypeScript

Having a `pedantic` option in TSConfig in addtion to `strict`

Ouverte
#56,028 7 commentaires 4 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Awaiting More Feedback Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.4k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

🔍 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
  1. What do you want to use this for?
    Learning to write the cleanest of TypeScript code.

  2. 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 by strict

  3. What workarounds are you using in the meantime?
    See the previous point

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

La proposition mentionne tsconfig.json ainsi que les options existantes strict et type-checking, mais aucun fichier d’implémentation ni test. Commencez par retracer la manière dont les options du compilateur sont regroupées et documentées, puis définissez les réglages inclus par pedantic et le comportement des remplacements individuels ; le travail est terminé lorsque l’option active systématiquement les vérifications prévues et qu’elle est couverte par des tests et de la documentation.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.