Skip to content

Enable all strictness options by default in TypeScript 7.0Β #63293

@sakgoyal

Description

@sakgoyal

πŸ” Search Terms

"opt out", "default", "strict", "tsconfig"

βœ… Viability Checklist

⭐ Suggestion

Enable all strictness-related compiler options by default starting in TypeScript 7.0.

Instead of requiring users to opt into strictness via flags like noImplicitAny, and strictNullChecks, all strictness options should default to true. Users should explicitly disable checks they do not want.

Additionally, any new strictness flags introduced in future versions should also be enabled by default automatically.

πŸ“ƒ Motivating Example

{ "compilerOptions": { "module": "nodenext", "target": "esnext", "types": ["node"], "moduleResolution": "nodenext", "declaration": true, "emitDeclarationOnly": true, "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "strict": true, "jsx": "react-jsx", "verbatimModuleSyntax": true, "isolatedModules": true, "noUncheckedSideEffectImports": true, "moduleDetection": "force", "skipLibCheck": true, "lib": ["esnext", "dom", "dom.iterable"], "noEmitOnError": false, "exactOptionalPropertyTypes": true, "noImplicitReturns": true, "noImplicitOverride": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "noPropertyAccessFromIndexSignature": true, "allowArbitraryExtensions": true, "allowUnreachableCode": false, "erasableSyntaxOnly": true, "noImplicitThis": true, "resolveJsonModule": true, "strictBuiltinIteratorReturn": true, "strictFunctionTypes": true, "noImplicitAny": true, "allowJs": false, "isolatedDeclarations": false, "allowImportingTsExtensions": true }, }

Would turn into something like:

{ "compilerOptions": { "module": "nodenext", "target": "esnext", "moduleResolution": "nodenext", "declaration": true, "emitDeclarationOnly": true, "jsx": "react-jsx", "isolatedModules": true, "moduleDetection": "force", "skipLibCheck": true, "lib": ["esnext", "dom", "dom.iterable"], "noEmitOnError": false, "allowArbitraryExtensions": true, "resolveJsonModule": true, "isolatedDeclarations": false, } }

πŸ’» Use Cases

  1. Reduce time spent configuring tsconfig.json (especially when starting fresh and not relying on older code bases)
  2. Ensure projects always use the safest and most modern type-checking defaults
  3. Avoid missing newly introduced strictness flags
  4. Strictness is opt-in, leading to inconsistent safety across projects (especially in larger orgs where not everyone keeps track of new options)
  5. stop manually adding new compiler options over time
  6. Reduce reliance on base configs or templates to set up new projects

Usually the options you don't want, is smaller and more consistent than the options you do want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions