Skip to content

Having a pedantic option in TSConfig in addtion to strict #56028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 tasks done
docwilco opened this issue Oct 8, 2023 · 7 comments
Open
5 tasks done

Having a pedantic option in TSConfig in addtion to strict #56028

docwilco opened this issue Oct 8, 2023 · 7 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@docwilco
Copy link

docwilco commented Oct 8, 2023

🔍 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

@jakebailey
Copy link
Member

FWIW you can achieve this by extending @tsconfig/strictest, which is now a lot easier now that we support multiple tsconfig extension.

@MartinJohns
Copy link
Contributor

@docwilco
Copy link
Author

docwilco commented Oct 9, 2023

I have responded to Ryan's gist.

@jakebailey that's super useful, thank you!

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Oct 9, 2023
@szankrisz
Copy link

I second that. I agree with @docwilco 's comments in the gist, especially to include in a particular error the very flag that lead to it being reported.

I'd like to use this flag as well in a form of front-runner CI build that warns me in advance of possible things to watch out for when new TypeScript versions arrive.

@zanminkian
Copy link

I agree. tsconfig.json has too much config options now! With --pedantic, we can explain it like: This option is the strictest option that is stricter than --strict.. Just enabling --strict and --pedantic, I don't need to care about too much about other options.

@ritschwumm
Copy link

ritschwumm commented May 13, 2024

ha ha only serious: just make pedantic the default and let people take off the guard rails if they think they have to.

@rauschma
Copy link

rauschma commented Apr 3, 2025

Another possibility is an option typeCheckingStrictness or typeCheckingLevel, e.g. with these settings:

  • "default"
  • "strict"
  • "pedantic"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

8 participants