microsoft / microsoft/TypeScript

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

Open
#56,028 7 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The proposal names tsconfig.json and the existing strict and type-checking options, but no implementation files or tests. Start by tracing how compiler options are grouped and documented, then define which settings pedantic includes and how individual overrides behave; done means the option consistently enables the intended checks and is covered by tests and documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.