Skip to content

Instantly share code, notes, and snippets.

@barhatsor
Last active July 22, 2026 10:08
Show Gist options
  • Select an option

  • Save barhatsor/bd9675b33c19c4b2a169cbf561ce894d to your computer and use it in GitHub Desktop.

Select an option

Save barhatsor/bd9675b33c19c4b2a169cbf561ce894d to your computer and use it in GitHub Desktop.
Useful TypeScript defaults.
{
// Note: This assumes TS6+.
"compilerOptions": {
// Treat all files as ES modules.
"moduleDetection": "force",
// For Node.js:
// "module": "nodenext",
// "types": ["node"],
// In arr: string[], arr[0] correctly becomes 'string | undefined'
// instead of incorrect 'string'.
"noUncheckedIndexedAccess": true,
// Non-empty switch cases without return/break/throw (implicit fallthrough) will error.
"noFallthroughCasesInSwitch": true,
// Require explicit 'override' keyword in front of overriding class methods.
"noImplicitOverride": true,
// Require importing and exporting types with the explicit 'type' keyword prefix.
"verbatimModuleSyntax": true,
// Force explicitly returning a value (instead of implicitly returning undefined)
// for all code paths if a function doesn't return void (already returns a value for some code paths).
"noImplicitReturns": true,
// obj: { optional?: string } will error when explicitly setting obj.optional = undefined
// (it would otherwise create inconsistent behavior for 'x in y' checks).
"exactOptionalPropertyTypes": true,
// Force explicit indexed access (instead of dot access) for generic index signature properties
// (eg. obj: { [key: string]: string } would have to be accessed using obj['prop'] instead of obj.prop).
"noPropertyAccessFromIndexSignature": true,
// Disallow enums, namespaces and modules with runtime code, parameter properties in classes,
// and some legacy syntax (the <prefix>-style type assertions syntax and CommonJS import/export assignments).
"erasableSyntaxOnly": true,
// Don't type check any declaration (.d.ts) files, gaining performance and convenience at the cost of
// losing type safety at the library boundary (relying on library authors to maintain accurate declarations).
"skipLibCheck": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment