Loading...
Loading...
TypeScript strict mode configuration for 2025. Recommended tsconfig.json settings, strict flags explained, moduleResolution strategies (Bundler vs NodeNext), verbatimModuleSyntax, noUncheckedIndexedAccess. Use when setting up TypeScript projects or migrating to stricter type safety.
npx skill4agent add laurigates/claude-plugins typescript-strict| Use this skill when... | Use another approach when... |
|---|---|
| Setting up a new TypeScript project | Debugging runtime errors (use debugger) |
| Migrating to stricter type safety | Configuring build tools (use bundler docs) |
| Choosing moduleResolution strategy | Writing application logic |
| Enabling noUncheckedIndexedAccess | Optimizing bundle size (use bundler skills) |
{
"compilerOptions": {
// Type Checking
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
// Modules
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"verbatimModuleSyntax": true,
// Emit
"target": "ES2022",
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"removeComments": false,
"noEmit": false,
// Interop
"isolatedModules": true,
"allowJs": false,
"checkJs": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "build"]
}strict: true{
"strict": true
// Equivalent to:
// "noImplicitAny": true,
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictBindCallApply": true,
// "strictPropertyInitialization": true,
// "noImplicitThis": true,
// "alwaysStrict": true
}strict: true| Flag | Purpose |
|---|---|
| Index signatures return |
| Require |
| Force bracket notation for index signatures |
| Prevent fallthrough in switch statements |
| Optional properties cannot be set to |
noUncheckedIndexedAccess// With noUncheckedIndexedAccess
const users: Record<string, User> = {};
const user = users['john'];
// Type: User | undefined (correct - must check before use)
if (user) {
console.log(user.name); // Type narrowed to User
}| Strategy | Use For | Extensions Required |
|---|---|---|
| Vite, Webpack, Bun projects | No |
| Node.js libraries and servers | Yes ( |
moduleResolution: "Bundler"{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler"
}
}exportsmoduleResolution: "NodeNext"{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}type: "module".js.ts{
"compilerOptions": {
"verbatimModuleSyntax": true
}
}// Error: 'User' is a type and must be imported with 'import type'
import { User } from './types';
// Correct
import type { User } from './types';
// Correct (mixed import)
import { fetchUser, type User } from './api';importsNotUsedAsValuespreserveValueImports| Context | Command |
|---|---|
| Check errors | |
| Check single file | |
| Show config | |
| Check module resolution | |
| Flag | Value | Category |
|---|---|---|
| | Type Checking |
| | Type Checking |
| | Type Checking |
| | Type Checking |
| | Type Checking |
| | Modules |
| | Modules |
| | Modules |
| | Emit |
| | Interop |
| | Interop |