frontend/config/ts-config/README.md
Shared TypeScript configuration presets for the Coze Bot Studio platform
This package provides standardized TypeScript configuration presets for all projects within the Coze Bot Studio monorepo. It offers multiple configuration options optimized for different project types (web applications, Node.js services, and base configurations) while ensuring consistency across the entire platform. The configurations include strict type checking, modern JavaScript features, and appropriate compiler options for optimal development experience and build performance.
Add this package to your package.json dependencies and set it to workspace:* version:
{
"devDependencies": {
"@coze-arch/ts-config": "workspace:*"
}
}
Then run:
rush update
Create a tsconfig.json file in your project root:
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
{
"extends": "@coze-arch/ts-config/tsconfig.node.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": [
"src/**/*"
]
}
{
"extends": "@coze-arch/ts-config/tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"outDir": "./dist"
}
}
For projects that need separate build configurations:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"removeComments": true
},
"exclude": [
"**/*.test.ts",
"**/*.spec.ts",
"__tests__/**/*"
]
}
tsconfig.web.jsonOptimized for web applications with React support.
Key Features:
react-jsx runtime{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@/*": ["*"],
"@components/*": ["components/*"]
}
}
}
tsconfig.node.jsonConfigured for Node.js applications and services.
Key Features:
{
"extends": "@coze-arch/ts-config/tsconfig.node.json",
"compilerOptions": {
"types": ["node", "jest"]
}
}
tsconfig.base.jsonBase configuration suitable for libraries and shared packages.
Key Features:
All configurations include these base settings:
{
"strict": true, // Enable all strict type checking
"noImplicitReturns": true, // Error on missing return statements
"noFallthroughCasesInSwitch": true, // Error on fallthrough cases
"noUncheckedIndexedAccess": true, // Strict array/object access
"exactOptionalPropertyTypes": true, // Exact optional property matching
"skipLibCheck": true, // Skip type checking of declaration files
"forceConsistentCasingInFileNames": true // Enforce consistent file naming
}
For monorepo projects with dependencies:
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"references": [
{ "path": "../shared-utils" },
{ "path": "../ui-components" }
],
"compilerOptions": {
"composite": true
}
}
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@utils/*": ["src/utils/*"],
"@components/*": ["src/components/*"],
"@shared/*": ["../shared/src/*"]
}
}
}
Development:
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"compilerOptions": {
"sourceMap": true,
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo"
}
}
Production:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"removeComments": true,
"declaration": false
}
}
The configurations are static JSON files, but the package includes:
.
├── tsconfig.base.json # Base configuration
├── tsconfig.web.json # Web application preset
├── tsconfig.node.json # Node.js service preset
├── global.d.ts # Global type declarations
└── examples/ # Usage examples
├── web-app/
├── node-service/
└── library/
When adding new TypeScript configurations:
tsconfig.base.json for consistencyexamples/ directoryThis package is maintained to be compatible with:
This package has minimal dependencies:
@coze-arch/eslint-config - ESLint configuration for linting this packagetypescript - TypeScript compiler for validationtypescript ^4.9.0 - Required by consuming projectsApache-2.0