typescript-strict
TypeScript strict mode: tsconfig.json, strict flags, Bundler/NodeNext moduleResolution, verbatimModuleSyntax. Use when setting up TS or migrating to stricter type safety.
What this skill does
# TypeScript Strict Mode
Modern TypeScript configuration with strict type checking for maximum safety and developer experience. This guide focuses on TypeScript 5.x best practices for 2025.
## When to Use This Skill
| 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) |
## Core Expertise
**What is Strict Mode?**
- **Type safety**: Catch more bugs at compile time
- **Better IDE experience**: Improved autocomplete and refactoring
- **Maintainability**: Self-documenting code with explicit types
- **Modern defaults**: Align with current TypeScript best practices
**Key Capabilities**
- Strict null checking
- Strict function types
- No implicit any
- No unchecked indexed access
- Proper module resolution
- Modern import/export syntax enforcement
## Recommended tsconfig.json (2025)
### Minimal Production Setup
```json
{
"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 Flags Explained
### `strict: true` (Umbrella Flag)
Enables all strict type-checking options:
```json
{
"strict": true
// Equivalent to:
// "noImplicitAny": true,
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictBindCallApply": true,
// "strictPropertyInitialization": true,
// "noImplicitThis": true,
// "alwaysStrict": true
}
```
**Always enable `strict: true` for new projects.**
### Additional Strict Flags (Recommended for 2025)
| Flag | Purpose |
|------|---------|
| `noUncheckedIndexedAccess` | Index signatures return `T \| undefined` instead of `T` |
| `noImplicitOverride` | Require `override` keyword for overridden methods |
| `noPropertyAccessFromIndexSignature` | Force bracket notation for index signatures |
| `noFallthroughCasesInSwitch` | Prevent fallthrough in switch statements |
| `exactOptionalPropertyTypes` | Optional properties cannot be set to `undefined` explicitly |
### `noUncheckedIndexedAccess` (Essential)
```typescript
// 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
}
```
**Always enable this flag to prevent runtime errors.**
## Module Resolution
### Choosing a Strategy
| Strategy | Use For | Extensions Required |
|----------|---------|---------------------|
| `Bundler` | Vite, Webpack, Bun projects | No |
| `NodeNext` | Node.js libraries and servers | Yes (`.js`) |
### `moduleResolution: "Bundler"` (Vite/Bun)
```json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler"
}
}
```
- No file extensions required in imports
- JSON imports without assertions
- Package.json `exports` field support
### `moduleResolution: "NodeNext"` (Node.js)
```json
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
```
- Respects package.json `type: "module"`
- Requires explicit `.js` extensions (even for `.ts` files)
- Supports conditional exports
## verbatimModuleSyntax (Recommended for 2025)
Prevents TypeScript from rewriting imports/exports.
```json
{
"compilerOptions": {
"verbatimModuleSyntax": true
}
}
```
```typescript
// 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';
```
**Replaces** deprecated `importsNotUsedAsValues` and `preserveValueImports`.
## Agentic Optimizations
| Context | Command |
|---------|---------|
| Check errors | `bunx tsc --noEmit` |
| Check single file | `bunx tsc --noEmit src/utils.ts` |
| Show config | `bunx tsc --showConfig` |
| Check module resolution | `bunx tsc --showConfig \| grep moduleResolution` |
## Quick Reference
### Recommended Flags
| Flag | Value | Category |
|------|-------|----------|
| `strict` | `true` | Type Checking |
| `noUncheckedIndexedAccess` | `true` | Type Checking |
| `noImplicitOverride` | `true` | Type Checking |
| `noPropertyAccessFromIndexSignature` | `true` | Type Checking |
| `noFallthroughCasesInSwitch` | `true` | Type Checking |
| `module` | `ESNext` / `NodeNext` | Modules |
| `moduleResolution` | `Bundler` / `NodeNext` | Modules |
| `verbatimModuleSyntax` | `true` | Modules |
| `target` | `ES2022` | Emit |
| `isolatedModules` | `true` | Interop |
| `skipLibCheck` | `true` | Interop |
For detailed examples, advanced patterns, and best practices, see [REFERENCE.md](REFERENCE.md).
## References
- TypeScript Handbook: https://www.typescriptlang.org/docs/handbook/intro.html
- TSConfig Reference: https://www.typescriptlang.org/tsconfig
- Strict Mode Guide: https://www.typescriptlang.org/tsconfig#strict
- Module Resolution: https://www.typescriptlang.org/docs/handbook/module-resolution.html
- Best Practices: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.