TypeScript Configurations
Relevant source files
The following files were used as context for generating this wiki page:
TypeScript configurations in the wrelik-kit repository provide a standardized, reusable foundation for all packages and applications within the monorepo. By utilizing a central @wrelik/tsconfig package, the project ensures consistent compiler behavior, strict type-checking, and optimized build outputs across different environments such as Node.js and Next.js.
The system is designed around a hierarchical inheritance model where a base configuration defines core rules, and specialized configurations extend it to support specific runtime requirements. This approach reduces duplication and enforces a "standardized integration" core principle across the ecosystem.
Sources: README.md:38-39, README.md:65-67
Architecture and Hierarchy
The TypeScript configuration architecture follows a modular pattern. The @wrelik/tsconfig package exports three primary JSON configurations: base.json, node.json, and next.json. Individual packages within the monorepo then extend these configurations based on their target environment.
The diagram above illustrates how the shared configurations serve as the foundation for specific package-level settings.
Sources: packages/tsconfig/package.json:11-13, packages/storage/tsconfig.json:1-3, packages/auth/tsconfig.json:1-3
Shared Configuration Packages
Base Configuration (base.json)
The base.json file defines the fundamental compiler options used by every package in the kit. It prioritizes strictness and modern module resolution.
| Option | Value | Description |
|---|---|---|
strict | true | Enables all strict type-checking options. |
moduleResolution | "bundler" | Optimizes resolution for modern bundlers. |
declaration | true | Generates corresponding .d.ts files. |
declarationMap | true | Generates a sourcemap for declaration files. |
esModuleInterop | true | Enables interoperability between CommonJS and ES Modules. |
skipLibCheck | true | Skips type checking of declaration files (.d.ts). |
Sources: packages/tsconfig/base.json:4-21
Node.js Configuration (node.json)
The node.json configuration extends the base settings to optimize for Node.js environments. It targets es2022 and uses the NodeNext module system to ensure compatibility with modern Node.js features and ESM/CJS resolution patterns.
{
"extends": "./base.json",
"compilerOptions": {
"lib": ["es2022"],
"module": "NodeNext",
"target": "es2022"
}
}
Sources: packages/tsconfig/node.json:1-8
Next.js Configuration (next.json)
Specialized for frontend applications and packages that interface with the Next.js framework, such as @wrelik/auth. It includes configurations for JSX preservation and Next.js specific plugins.
| Option | Value | Purpose |
|---|---|---|
jsx | "preserve" | Required for Next.js to handle JSX transformations. |
lib | ["dom", "dom.iterable", "esnext"] | Includes browser-specific type definitions. |
plugins | [{ "name": "next" }] | Enables the Next.js TypeScript plugin. |
noEmit | true | Next.js handles the actual emission of files. |
Sources: packages/tsconfig/next.json:4-16
Package-Level Implementation
Individual packages within the packages/ directory implement their own tsconfig.json by extending the appropriate shared config. This allows packages to override specific settings, such as the output directory (outDir), while maintaining the global standard.
Example: Storage Package Implementation
The @wrelik/storage package uses the Node.js configuration as it is a server-side adapter for S3/R2.
{
"extends": "@wrelik/tsconfig/node.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"]
}
Sources: packages/storage/tsconfig.json:1-7
Example: Auth Package Implementation
The @wrelik/auth package extends the Next.js configuration because it provides high-level Next.js integration for authentication.
{
"extends": "@wrelik/tsconfig/next.json",
"compilerOptions": {
"incremental": false,
"outDir": "dist"
},
"include": ["src"]
}
Sources: packages/auth/tsconfig.json:1-8
Summary of Usage
The TypeScript configuration system in wrelik-kit ensures that all adapters and utilities are built with consistent rules. By centralizing these settings in @wrelik/tsconfig, the project maintains high code quality and simplifies the process of adding new packages to the monorepo.
Sources: README.md:1-10, README.md:38-39