Overview
The SAAC Frontend template uses TypeScript 5.8.x with strict type checking enabled. The TypeScript configuration is split across three files for better organization.Configuration Files
The template uses a project references setup with three TypeScript configuration files:- tsconfig.json - Root configuration that references the other configs
- tsconfig.app.json - Configuration for application source code
- tsconfig.node.json - Configuration for Node.js tooling (Vite config)
Root Configuration
tsconfig.json
The root
tsconfig.json doesn’t contain any files itself. It only serves as an entry point that references the specialized configurations.Application Configuration
The main TypeScript configuration for your React application:tsconfig.app.json
Compiler Options Explained
Build Configuration
Location for incremental build info cache. Stored in
node_modules/.tmp to avoid cluttering the project root.The ECMAScript target version for compiled output. ES2022 includes features like top-level await and class fields.
Type definitions to include:
- ES2022: Modern JavaScript APIs
- DOM: Browser APIs (document, window, etc.)
- DOM.Iterable: Iterable DOM collections
Module system to use. ESNext enables the latest ES module features.
Skip type checking of declaration files (.d.ts). Speeds up compilation significantly.
Bundler Mode Settings
What is Bundler Mode?
What is Bundler Mode?
Bundler mode (
"moduleResolution": "bundler") is optimized for modern bundlers like Vite, webpack, and esbuild. It enables:- Importing TypeScript files directly (
.ts,.tsx) - Resolution that matches how bundlers work
- Better tree-shaking and optimization
Use bundler-specific module resolution algorithm.
Allow importing
.ts and .tsx files directly in imports.Ensure
import type and export type are preserved. Improves tree-shaking.Treat all files as modules (even without imports/exports).
Don’t emit JavaScript output. Vite handles transpilation, TypeScript only does type checking.
JSX Configuration
JSX transformation mode:
- react-jsx: Modern automatic runtime (no need to import React)
- react: Classic runtime (requires
import React from 'react')
The
react-jsx mode enables the new JSX transform introduced in React 17+, eliminating the need to import React in every file.Strict Type Checking
Enable all strict type checking options:
- strictNullChecks
- strictFunctionTypes
- strictBindCallApply
- strictPropertyInitialization
- noImplicitThis
- alwaysStrict
Report errors on unused local variables.
Report errors on unused function parameters.
Ensure only type-level TypeScript syntax is used (enforces proper separation of types and runtime code).
Prevent fallthrough cases in switch statements.
Ensure all imports are used or explicitly marked as side-effect imports.
Node Configuration
Configuration for Node.js tooling files (likevite.config.ts):
tsconfig.node.json
Key Differences from App Config
Why a separate Node config?
Why a separate Node config?
The Node configuration differs from the app configuration in a few ways:
- Target: ES2023 instead of ES2022 (Node.js supports newer features)
- Lib: Only ES2023, no DOM types (Node.js environment)
- Include: Only
vite.config.ts, not the entiresrcdirectory
- Build tooling code doesn’t accidentally use browser APIs
- App code doesn’t accidentally use Node.js APIs
- Faster type checking (smaller scope per config)
Type Checking
During Development
Vite performs runtime transpilation only during development. Type checking happens:- In your editor (via TypeScript language server)
- On demand when you run
tscmanually
This approach keeps HMR fast. Type errors don’t block the dev server.
Before Production Build
The build command runs type checking before bundling:package.json
tsc -b command:
- Type checks all project references
- Uses incremental compilation
- Fails the build if type errors are found
Path Aliases
To add path aliases, updatetsconfig.app.json:
tsconfig.app.json
Remember to also configure matching aliases in
vite.config.ts for runtime module resolution.Type Declarations
The template includes a type declaration file:src/vite-env.d.ts
import.meta.env(Vite environment variables)- Asset imports (images, SVGs, etc.)
- Special Vite features
Adding Custom Type Declarations
Create additional.d.ts files in src/ for custom types:
src/custom.d.ts
Common Customizations
Disable Strict Mode
tsconfig.app.json
Allow JavaScript Files
tsconfig.app.json
Enable Decorators
tsconfig.app.json
