@codefast/typescript-config 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @codefast/typescript-config
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`33639d4`](https://github.com/codefastlabs/codefast/commit/33639d4a8698fb45815295fec5aa53ff8d4b72eb) Thanks [@thevuong](https://github.com/thevuong)! - feat(image-loader): integrate `query-string` for streamlined URL generation
8
+
9
+ - [`ec7cc53`](https://github.com/codefastlabs/codefast/commit/ec7cc53f90eb466d89ce8327e18185fbbd13420b) Thanks [@thevuong](https://github.com/thevuong)! - feat(turbo): add `lint:ci` task with build dependency
10
+
11
+ - [`728caa2`](https://github.com/codefastlabs/codefast/commit/728caa2b60273623e15543b2ef0963f0cc53d99f) Thanks [@thevuong](https://github.com/thevuong)! - chore(deps): update @types/node to v24.0.14 across packages
12
+
13
+ - [`f9c5603`](https://github.com/codefastlabs/codefast/commit/f9c5603dbe8f318251ec6f8c2e54137122dc2cd4) Thanks [@thevuong](https://github.com/thevuong)! - feat(docs): add Chrome DevTools integration and simplify scripts
14
+
15
+ - [`3c58590`](https://github.com/codefastlabs/codefast/commit/3c58590419ccc95a564c5c9eef79679c1f93f32e) Thanks [@thevuong](https://github.com/thevuong)! - chore(eslint-config): remove all custom ESLint configuration files
16
+
17
+ - [`a5b2a35`](https://github.com/codefastlabs/codefast/commit/a5b2a35b1a1f69442a0144eab392ef3effcfee66) Thanks [@thevuong](https://github.com/thevuong)! - feat(docs): update web app manifest and improve Biome configuration
18
+
19
+ - [`3c58590`](https://github.com/codefastlabs/codefast/commit/3c58590419ccc95a564c5c9eef79679c1f93f32e) Thanks [@thevuong](https://github.com/thevuong)! - chore(eslint): remove custom ESLint configurations and related files
20
+
21
+ - [`0a6c826`](https://github.com/codefastlabs/codefast/commit/0a6c826f30d4dccb557eaeb8ba32e8ef82c164dd) Thanks [@thevuong](https://github.com/thevuong)! - feat(eslint-config): introduce shared ESLint configuration package for consistent linting rules
22
+
3
23
  ## 0.3.5
4
24
 
5
25
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,337 @@
1
+ # @codefast/typescript-config
2
+
3
+ Shared TypeScript configuration presets for the CodeFast monorepo, providing consistent and optimized TypeScript settings across different project types including libraries, React applications, and Next.js projects.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **Multiple Presets** - Tailored configurations for different project types
8
+ - 🏗️ **Extensible Base** - Common base configuration with specialized extensions
9
+ - ⚡ **Modern Standards** - Latest TypeScript features and best practices
10
+ - 🔧 **Strict Configuration** - Enhanced type safety and code quality
11
+ - 📦 **Monorepo Optimized** - Designed for monorepo development workflows
12
+ - 🚀 **Performance Focused** - Optimized compiler options for fast builds
13
+
14
+ ## Available Configurations
15
+
16
+ ### Base Configuration (`base.json`)
17
+
18
+ Foundational TypeScript configuration with strict settings and modern ES features:
19
+
20
+ - ES2022 target with ESNext modules
21
+ - Strict type checking enabled
22
+ - Declaration files and source maps
23
+ - Optimized for development and production builds
24
+
25
+ ### Library Configuration (`library.json`)
26
+
27
+ Extends base configuration for library development:
28
+
29
+ - Composite builds support
30
+ - Incremental compilation
31
+ - Source maps and declaration maps
32
+ - Internal type stripping for clean APIs
33
+
34
+ ### React Configuration (`react.json`)
35
+
36
+ Optimized for React components and applications:
37
+
38
+ - React JSX transform (`react-jsx`)
39
+ - React as JSX import source
40
+ - ES2020 target for modern React features
41
+ - Source maps for debugging
42
+
43
+ ### Next.js Configuration (`next.json`)
44
+
45
+ Tailored for Next.js applications:
46
+
47
+ - Next.js plugin integration
48
+ - JSX preserve mode
49
+ - JavaScript file support
50
+ - ES2018 target for Next.js compatibility
51
+ - No emit (Next.js handles compilation)
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ # Using pnpm (recommended)
57
+ pnpm add -D @codefast/typescript-config
58
+
59
+ # Using npm
60
+ npm install --save-dev @codefast/typescript-config
61
+
62
+ # Using yarn
63
+ yarn add -D @codefast/typescript-config
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ ### For Libraries
69
+
70
+ Create a `tsconfig.json` in your library package:
71
+
72
+ ```json
73
+ {
74
+ "extends": "@codefast/typescript-config/library.json",
75
+ "compilerOptions": {
76
+ "outDir": "./dist",
77
+ "rootDir": "./src"
78
+ },
79
+ "include": ["src/**/*"],
80
+ "exclude": ["dist", "node_modules", "**/*.test.ts", "**/*.spec.ts"]
81
+ }
82
+ ```
83
+
84
+ ### For React Applications
85
+
86
+ Create a `tsconfig.json` for React projects:
87
+
88
+ ```json
89
+ {
90
+ "extends": "@codefast/typescript-config/react.json",
91
+ "compilerOptions": {
92
+ "paths": {
93
+ "@/*": ["./src/*"]
94
+ }
95
+ },
96
+ "include": ["src/**/*"],
97
+ "exclude": ["node_modules", "dist", "build"]
98
+ }
99
+ ```
100
+
101
+ ### For Next.js Applications
102
+
103
+ Create a `tsconfig.json` for Next.js projects:
104
+
105
+ ```json
106
+ {
107
+ "extends": "@codefast/typescript-config/next.json",
108
+ "compilerOptions": {
109
+ "paths": {
110
+ "@/*": ["./src/*"]
111
+ }
112
+ },
113
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
114
+ "exclude": ["node_modules"]
115
+ }
116
+ ```
117
+
118
+ ### For Custom Configurations
119
+
120
+ You can extend the base configuration and customize it:
121
+
122
+ ```json
123
+ {
124
+ "extends": "@codefast/typescript-config/base.json",
125
+ "compilerOptions": {
126
+ "outDir": "./build",
127
+ "rootDir": "./src",
128
+ "paths": {
129
+ "@/*": ["./src/*"],
130
+ "@components/*": ["./src/components/*"]
131
+ }
132
+ },
133
+ "include": ["src/**/*"],
134
+ "exclude": ["node_modules", "build", "**/*.test.ts"]
135
+ }
136
+ ```
137
+
138
+ ## Build Configuration
139
+
140
+ For build-specific configurations, create a separate `tsconfig.build.json`:
141
+
142
+ ```json
143
+ {
144
+ "extends": "./tsconfig.json",
145
+ "compilerOptions": {
146
+ "noEmit": false,
147
+ "declaration": true,
148
+ "declarationMap": true,
149
+ "sourceMap": true
150
+ },
151
+ "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts", "**/*.stories.ts"]
152
+ }
153
+ ```
154
+
155
+ ## Configuration Details
156
+
157
+ ### Compiler Options Explained
158
+
159
+ This section explains the meaning and purpose of each TypeScript compiler option used across our configurations.
160
+
161
+ #### Base Configuration Options (`base.json`)
162
+
163
+ **Module and Import Settings:**
164
+
165
+ - `allowImportingTsExtensions: false` - Prevents importing TypeScript files with `.ts` extensions, enforcing proper module resolution
166
+ - `allowSyntheticDefaultImports: true` - Allows default imports from modules without default exports (e.g., `import React from 'react'`)
167
+ - `esModuleInterop: true` - Enables interoperability between CommonJS and ES modules, making imports more intuitive
168
+ - `module: "ESNext"` - Uses the latest ECMAScript module system for modern bundlers
169
+ - `moduleDetection: "force"` - Forces TypeScript to treat all files as modules, preventing global scope pollution
170
+ - `moduleResolution: "node"` - Uses Node.js-style module resolution for better compatibility with Node.js and npm packages
171
+ - `resolveJsonModule: true` - Allows importing JSON files as modules with type safety
172
+
173
+ **Type Checking and Safety:**
174
+
175
+ - `strict: true` - Enables all strict type checking options for maximum type safety
176
+ - `noImplicitReturns: true` - Ensures all code paths in functions return a value when a return type is specified
177
+ - `noImplicitOverride: true` - Requires explicit `override` keyword when overriding base class methods
178
+ - `noFallthroughCasesInSwitch: true` - Prevents accidental fallthrough in switch statements
179
+ - `noUnusedLocals: true` - Reports errors for unused local variables
180
+ - `noUnusedParameters: true` - Reports errors for unused function parameters
181
+ - `forceConsistentCasingInFileNames: true` - Ensures consistent file name casing across different operating systems
182
+
183
+ **Output and Declaration:**
184
+
185
+ - `declaration: true` - Generates `.d.ts` declaration files for type definitions
186
+ - `declarationMap: true` - Creates source maps for declaration files, enabling "Go to Definition" in editors
187
+ - `incremental: false` - Disables incremental compilation in base config (overridden in specific configs)
188
+ - `noEmitOnError: true` - Prevents emitting JavaScript files when TypeScript errors are present
189
+
190
+ **Language Features:**
191
+
192
+ - `target: "ES2022"` - Compiles to ES2022, supporting modern JavaScript features
193
+ - `lib: ["DOM", "DOM.Iterable", "ESNext"]` - Includes type definitions for DOM APIs and latest ECMAScript features
194
+ - `isolatedModules: true` - Ensures each file can be transpiled independently (required for tools like Babel)
195
+ - `useDefineForClassFields: true` - Uses ECMAScript standard behavior for class field declarations
196
+ - `verbatimModuleSyntax: false` - Allows TypeScript to transform import/export syntax for better compatibility
197
+
198
+ **Performance and Optimization:**
199
+
200
+ - `skipLibCheck: true` - Skips type checking of declaration files for faster compilation
201
+
202
+ #### Library Configuration Options (`library.json`)
203
+
204
+ **Build System:**
205
+
206
+ - `composite: true` - Enables TypeScript project references for monorepo builds and incremental compilation
207
+ - `incremental: true` - Enables incremental compilation for faster subsequent builds
208
+ - `sourceMap: true` - Generates source maps for debugging compiled JavaScript
209
+
210
+ **Output Control:**
211
+
212
+ - `noEmit: false` - Allows emitting JavaScript files (overrides base config for library builds)
213
+ - `removeComments: false` - Preserves comments in output for better debugging experience
214
+ - `stripInternal: true` - Removes types marked with `@internal` from declaration files, creating cleaner public APIs
215
+
216
+ **Library-Specific:**
217
+
218
+ - `lib: ["ESNext"]` - Only includes ESNext types (removes DOM types for Node.js libraries)
219
+
220
+ #### React Configuration Options (`react.json`)
221
+
222
+ **JSX Processing:**
223
+
224
+ - `jsx: "react-jsx"` - Uses the modern React JSX transform (no need to import React in every file)
225
+ - `jsxImportSource: "react"` - Specifies React as the source for JSX runtime functions
226
+
227
+ **Build Settings:**
228
+
229
+ - `target: "ES2020"` - Targets ES2020 for modern React applications
230
+ - `moduleResolution: "node"` - Uses Node.js-style module resolution for better compatibility with npm packages
231
+ - `noEmit: false` - Allows emitting files for React builds
232
+ - `sourceMap: true` - Enables source maps for debugging React components
233
+
234
+ #### Next.js Configuration Options (`next.json`)
235
+
236
+ **Next.js Integration:**
237
+
238
+ - `allowJs: true` - Allows JavaScript files alongside TypeScript in Next.js projects
239
+ - `jsx: "preserve"` - Preserves JSX syntax for Next.js to handle during its compilation process
240
+ - `plugins: [{"name": "next"}]` - Integrates Next.js TypeScript plugin for enhanced IDE support
241
+ - `noEmit: true` - Prevents TypeScript from emitting files (Next.js handles compilation)
242
+
243
+ **Compatibility:**
244
+
245
+ - `target: "ES2018"` - Targets ES2018 for broader browser compatibility in Next.js apps
246
+ - `moduleResolution: "node"` - Uses Node.js-style module resolution for better compatibility with npm packages
247
+ - `incremental: true` - Enables incremental compilation for faster Next.js development builds
248
+
249
+ ### Configuration Inheritance
250
+
251
+ Each configuration extends the base configuration and overrides specific options:
252
+
253
+ - **Library** extends base + adds composite builds, source maps, and library-specific optimizations
254
+ - **React** extends base + adds JSX support and React-specific settings
255
+ - **Next.js** extends base + adds Next.js plugin integration and framework-specific optimizations
256
+
257
+ ## Best Practices
258
+
259
+ ### Monorepo Setup
260
+
261
+ For monorepo packages, use project references in your root `tsconfig.json`:
262
+
263
+ ```json
264
+ {
265
+ "files": [],
266
+ "references": [
267
+ {
268
+ "path": "./packages/ui"
269
+ },
270
+ {
271
+ "path": "./packages/hooks"
272
+ },
273
+ {
274
+ "path": "./apps/docs"
275
+ }
276
+ ]
277
+ }
278
+ ```
279
+
280
+ ### Path Mapping
281
+
282
+ Configure consistent path mapping across your projects:
283
+
284
+ ```json
285
+ {
286
+ "compilerOptions": {
287
+ "paths": {
288
+ "@/*": ["./src/*"],
289
+ "@/components/*": ["./src/components/*"],
290
+ "@/utils/*": ["./src/utils/*"],
291
+ "@/types/*": ["./src/types/*"]
292
+ }
293
+ }
294
+ }
295
+ ```
296
+
297
+ ### Development vs Production
298
+
299
+ Use different configurations for development and production builds:
300
+
301
+ ```json5
302
+ // tsconfig.dev.json
303
+ {
304
+ extends: "./tsconfig.json",
305
+ compilerOptions: {
306
+ incremental: true,
307
+ tsBuildInfoFile: ".tsbuildinfo",
308
+ },
309
+ }
310
+ ```
311
+
312
+ ## Troubleshooting
313
+
314
+ ### Common Issues
315
+
316
+ 1. **Module Resolution Errors**: Ensure `moduleResolution` is set to `"node"` for better npm package compatibility
317
+ 2. **JSX Errors**: Use the appropriate preset (`react.json` or `next.json`) for JSX projects
318
+ 3. **Declaration Errors**: Check that `declaration` is enabled for library builds
319
+ 4. **Path Mapping**: Verify `baseUrl` and `paths` are correctly configured
320
+
321
+ ### Performance Tips
322
+
323
+ - Use `incremental: true` for faster subsequent builds
324
+ - Enable `composite: true` for project references in monorepos
325
+ - Use `skipLibCheck: true` to skip type checking of declaration files
326
+
327
+ ## Contributing
328
+
329
+ This package is part of the CodeFast monorepo. For contributions, please refer to the main repository guidelines.
330
+
331
+ ## License
332
+
333
+ MIT License - see the [LICENSE](../../LICENSE) file for details.
334
+
335
+ ---
336
+
337
+ **@codefast/typescript-config** provides the foundation for consistent TypeScript development across the CodeFast ecosystem.
package/base.json CHANGED
@@ -1,21 +1,30 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
+ "allowImportingTsExtensions": false,
5
+ "allowSyntheticDefaultImports": true,
4
6
  "declaration": true,
5
7
  "declarationMap": true,
6
8
  "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
7
10
  "incremental": false,
8
11
  "isolatedModules": true,
9
12
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
10
13
  "module": "ESNext",
11
14
  "moduleDetection": "force",
12
- "moduleResolution": "bundler",
15
+ "moduleResolution": "node",
16
+ "noEmitOnError": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noImplicitOverride": true,
19
+ "noImplicitReturns": true,
13
20
  "noUnusedLocals": true,
14
21
  "noUnusedParameters": true,
15
22
  "resolveJsonModule": true,
16
23
  "skipLibCheck": true,
17
24
  "strict": true,
18
- "target": "ESNext"
25
+ "target": "ES2022",
26
+ "useDefineForClassFields": true,
27
+ "verbatimModuleSyntax": false
19
28
  },
20
- "display": "Default"
29
+ "display": "Base configuration for monorepo packages"
21
30
  }
package/library.json CHANGED
@@ -1,5 +1,16 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "Library",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "incremental": true,
8
+ "lib": ["ESNext"],
9
+ "noEmit": false,
10
+ "removeComments": false,
11
+ "sourceMap": true,
12
+ "stripInternal": true
13
+ },
14
+ "display": "Library development configuration",
4
15
  "extends": "./base.json"
5
16
  }
@@ -2,16 +2,20 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
4
  "allowJs": true,
5
+ "incremental": true,
5
6
  "jsx": "preserve",
7
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
8
  "module": "ESNext",
7
- "moduleResolution": "bundler",
9
+ "moduleResolution": "node",
8
10
  "noEmit": true,
9
11
  "plugins": [
10
12
  {
11
13
  "name": "next"
12
14
  }
13
- ]
15
+ ],
16
+ "resolveJsonModule": true,
17
+ "target": "ES2018"
14
18
  },
15
- "display": "Next.js",
19
+ "display": "Next.js application configuration",
16
20
  "extends": "./base.json"
17
21
  }
package/package.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "name": "@codefast/typescript-config",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
+ "description": "Shared TypeScript configuration for the monorepo",
5
+ "keywords": [
6
+ "typescript",
7
+ "tsconfig",
8
+ "configuration",
9
+ "monorepo",
10
+ "react",
11
+ "next",
12
+ "node",
13
+ "browser",
14
+ "library"
15
+ ],
16
+ "homepage": "https://github.com/codefastlabs/codefast/tree/main/packages/typescript-config#readme",
4
17
  "bugs": {
5
18
  "url": "https://github.com/codefastlabs/codefast/issues"
6
19
  },
@@ -12,11 +25,14 @@
12
25
  "license": "MIT",
13
26
  "author": "Vuong Phan <mr.thevuong@gmail.com>",
14
27
  "sideEffects": false,
28
+ "exports": {
29
+ "./base.json": "./base.json",
30
+ "./library.json": "./library.json",
31
+ "./next.json": "./next.json",
32
+ "./react.json": "./react.json"
33
+ },
15
34
  "files": [
16
- "base.json",
17
- "library.json",
18
- "nextjs.json",
19
- "react.json",
35
+ "*.json",
20
36
  "CHANGELOG.md",
21
37
  "README.md",
22
38
  "LICENSE"
package/react.json CHANGED
@@ -2,8 +2,13 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
4
  "jsx": "react-jsx",
5
- "moduleResolution": "bundler"
5
+ "jsxImportSource": "react",
6
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
7
+ "moduleResolution": "node",
8
+ "noEmit": false,
9
+ "sourceMap": true,
10
+ "target": "ES2020"
6
11
  },
7
- "display": "React",
12
+ "display": "React component and application configuration",
8
13
  "extends": "./base.json"
9
14
  }