Strict TypeScript configuration with all safety flags enabled. Use when initializing TypeScript projects or enforcing type safety.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill defines the strictest possible TypeScript configuration for maximum type safety.
Use this skill when:
ZERO TOLERANCE FOR any TYPES - Every value must have an explicit, meaningful type.
{
"compilerOptions": {
// Language & Environment
"target": "ES2022",
"lib": ["ES2022"],
"module": "ESNext",
"moduleResolution": "bundler",
// Emit
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"removeComments": false,
"importHelpers": true,
// Interop Constraints
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// Type Checking - ALL STRICT FLAGS
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
// Additional Checks
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"exactOptionalPropertyTypes": true,
// Completeness
"skipLibCheck": false,
"skipDefaultLibCheck": false
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}
any typethis expressions with implied any typeunknown (not any)T | undefined{
"scripts": {
"type-check": "tsc --noEmit",
"type-check:watch": "tsc --noEmit --watch",
"build": "tsc",
"clean": "rm -rf dist"
}
}
BAD:
function process(data: any) { // ❌
return data.value;
}
GOOD:
function isValidData(value: unknown): value is { value: string } {
return (
typeof value === 'object' &&
value !== null &&
'value' in value &&
typeof (value as Record<string, unknown>).value === 'string'
);
}
function process(data: unknown): string {
if (!isValidData(data)) {
throw new Error('Invalid data');
}
return data.value;
}
With noUncheckedIndexedAccess: true, array access returns T | undefined:
const numbers: number[] = [1, 2, 3];
// ❌ Type error - value is number | undefined
const first: number = numbers[0];
// ✅ Explicit check
const first = numbers[0];
if (first !== undefined) {
console.log(first.toFixed(2));
}
// ✅ Using optional chaining
console.log(numbers[0]?.toFixed(2));
// ✅ Using assertion (only if guaranteed)
const firstAsserted = numbers[0]!;
// ❌ Implicit null
let name: string = null; // Error with strictNullChecks
// ✅ Explicit null
let name: string | null = null;
// ✅ Narrowing
if (name !== null) {
console.log(name.toUpperCase());
}
// ✅ Optional chaining
console.log(name?.toUpperCase());
// ✅ Nullish coalescing
const displayName = name ?? 'Anonymous';
With useUnknownInCatchVariables: true:
// ❌ Old way (error is `any`)
try {
riskyOperation();
} catch (error) {
console.log(error.message); // Unsafe
}
// ✅ New way (error is `unknown`)
try {
riskyOperation();
} catch (error) {
if (error instanceof Error) {
console.log(error.message);
} else {
console.log('Unknown error:', error);
}
}
// ❌ Missing return type
function calculate(x: number) {
return x * 2;
}
// ✅ Explicit return type
function calculate(x: number): number {
return x * 2;
}
// ✅ Async function
async function fetchData(id: string): Promise<Data> {
const response = await fetch(`/api/data/${id}`);
return response.json() as Promise<Data>;
}
Add TypeScript ESLint rules to enforce strict typing:
// eslint.config.ts
import tseslint from 'typescript-eslint';
export default tseslint.config(
...tseslint.configs.strictTypeChecked,
{
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
},
},
);
strict: true// @ts-expect-error with justification for unavoidable casesany types (explicit or implicit)// @ts-ignore without justificationunknown instead of any for truly unknown typesany types