@codefast/typescript-config 0.3.10 → 0.3.11-canary.0

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +190 -142
  3. package/package.json +14 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @codefast/typescript-config
2
2
 
3
+ ## 0.3.11-canary.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [`135c6be`](https://github.com/codefastlabs/codefast/commit/135c6bed9d1bc1e96bad3173adab1bf32d74322f) Thanks [@thevuong](https://github.com/thevuong)! - chore: update linting and formatting scripts in package.json
8
+
9
+ - [`610cf7a`](https://github.com/codefastlabs/codefast/commit/610cf7a7f9b6e5b37be21e7675ea363ef1020639) Thanks [@thevuong](https://github.com/thevuong)! - fix(hooks): handle missing `navigator.clipboard.writeText` gracefully
10
+
11
+ - [`3e90474`](https://github.com/codefastlabs/codefast/commit/3e90474fbbb9f8ac626c5949bfdbac2eaf1cb3e8) Thanks [@thevuong](https://github.com/thevuong)! - chore: update project configuration and dependencies
12
+
13
+ - [`5c09d4c`](https://github.com/codefastlabs/codefast/commit/5c09d4ce2df564dc7ac6727b00cfa668164a1af4) Thanks [@thevuong](https://github.com/thevuong)! - refactor(config): rename `check-types` to `typecheck` and update usage
14
+
3
15
  ## 0.3.10
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,13 +1,45 @@
1
- # TypeScript Config
2
-
3
- Shared TypeScript configuration presets for the CodeFast monorepo, providing standardized TypeScript settings for different project types including React applications, Next.js projects, libraries, and base configurations.
4
-
5
- ![NPM Version](https://img.shields.io/npm/v/@codefast/typescript-config.svg)
1
+ # @codefast/typescript-config
2
+
3
+ Shared TypeScript configuration presets providing standardized compiler settings for different project types including base projects, libraries, React applications, and Next.js.
4
+
5
+ [![CI](https://github.com/codefastlabs/codefast/actions/workflows/release.yml/badge.svg)](https://github.com/codefastlabs/codefast/actions/workflows/release.yml)
6
+ [![npm version](https://img.shields.io/npm/v/@codefast/typescript-config.svg)](https://www.npmjs.com/package/@codefast/typescript-config)
7
+ [![npm downloads](https://img.shields.io/npm/dm/@codefast/typescript-config.svg)](https://www.npmjs.com/package/@codefast/typescript-config)
8
+ [![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ## Table of Contents
11
+
12
+ - [Overview](#overview)
13
+ - [Installation](#installation)
14
+ - [Quick Start](#quick-start)
15
+ - [Usage](#usage)
16
+ - [Base Configuration](#base-configuration)
17
+ - [Library Configuration](#library-configuration)
18
+ - [React Configuration](#react-configuration)
19
+ - [Next.js Configuration](#nextjs-configuration)
20
+ - [Configurations](#configurations)
21
+ - [API Reference](#api-reference)
22
+ - [Compatibility](#compatibility)
23
+ - [Troubleshooting](#troubleshooting)
24
+ - [Contributing](#contributing)
25
+ - [License](#license)
26
+ - [Changelog](#changelog)
27
+
28
+ ## Overview
29
+
30
+ `@codefast/typescript-config` provides opinionated, strict TypeScript presets that can be extended in any project. Each preset is tuned for a specific project type, so you get the right compiler options without manual configuration.
31
+
32
+ **Key features:**
33
+
34
+ - **Strict Type Checking** -- Enables all strict options for maximum type safety.
35
+ - **Modern JavaScript** -- Targets ESNext with full ESNext lib support.
36
+ - **Bundler Module Resolution** -- Optimized for modern bundlers (Vite, Turbopack, esbuild).
37
+ - **JavaScript Support** -- Allows `.js` files alongside TypeScript.
38
+ - **JSON Support** -- Resolves JSON modules natively.
39
+ - **Isolated Modules** -- Transpile each file separately for faster builds.
6
40
 
7
41
  ## Installation
8
42
 
9
- Install the package via pnpm (recommended):
10
-
11
43
  ```bash
12
44
  pnpm add -D @codefast/typescript-config
13
45
  ```
@@ -18,14 +50,14 @@ Or using npm:
18
50
  npm install --save-dev @codefast/typescript-config
19
51
  ```
20
52
 
21
- **Requirements**:
53
+ **Requirements:**
22
54
 
23
- - Node.js version 20.0.0 or higher
24
- - TypeScript version 5.0.0 or higher
55
+ - Node.js >= 24.0.0 (LTS)
56
+ - TypeScript >= 5.0.0
25
57
 
26
58
  ## Quick Start
27
59
 
28
- Create a `tsconfig.json` file in your project and extend from the appropriate configuration:
60
+ Create a `tsconfig.json` in your project root and extend from the appropriate preset:
29
61
 
30
62
  ```json
31
63
  {
@@ -37,7 +69,7 @@ Create a `tsconfig.json` file in your project and extend from the appropriate co
37
69
 
38
70
  ### Base Configuration
39
71
 
40
- Basic configuration for all TypeScript projects:
72
+ For general TypeScript projects:
41
73
 
42
74
  ```json
43
75
  {
@@ -52,7 +84,7 @@ Basic configuration for all TypeScript projects:
52
84
 
53
85
  ### Library Configuration
54
86
 
55
- For developing libraries and packages:
87
+ For NPM packages and shared libraries (no DOM libs):
56
88
 
57
89
  ```json
58
90
  {
@@ -88,184 +120,200 @@ For Next.js applications:
88
120
  ```json
89
121
  {
90
122
  "extends": "@codefast/typescript-config/next.json",
91
- "include": [
92
- "next-env.d.ts",
93
- "**/*.ts",
94
- "**/*.tsx",
95
- ".next/types/**/*.ts"
96
- ],
123
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
97
124
  "exclude": ["node_modules"]
98
125
  }
99
126
  ```
100
127
 
101
128
  ## Configurations
102
129
 
103
- ### Available Configurations
130
+ ### Available Presets
131
+
132
+ | Configuration | Extends | Description | Use Case |
133
+ | -------------- | ----------- | ------------------------------------------------ | ------------------------------ |
134
+ | `base.json` | -- | Strict base configuration with ESNext target | All TypeScript projects |
135
+ | `library.json` | `base.json` | ESNext-only libs (no DOM) | NPM packages, shared libraries |
136
+ | `react.json` | `base.json` | Adds `react-jsx` transform | React components and apps |
137
+ | `next.json` | `base.json` | Incremental builds, JSX preserve, Next.js plugin | Next.js applications |
104
138
 
105
- | Configuration | Description | Use Case |
106
- |---------------|-------------|----------|
107
- | `base.json` | Basic configuration with strict settings | Base for all projects |
108
- | `library.json` | Extends base, adds library-specific options | NPM packages, shared libraries |
109
- | `react.json` | Extends base, adds React JSX support | React components and apps |
110
- | `next.json` | Extends base, optimized for Next.js | Next.js applications |
139
+ ### Base Configuration Details
111
140
 
112
- ### Base Configuration Features
141
+ | Option | Value | Purpose |
142
+ | ------------------- | --------------------------- | ---------------------------------------- |
143
+ | `strict` | `true` | Enables all strict type-checking options |
144
+ | `target` | `ESNext` | Latest JavaScript features |
145
+ | `module` | `ESNext` | ESM module system |
146
+ | `moduleResolution` | `bundler` | Optimized for modern bundlers |
147
+ | `lib` | `DOM, DOM.Iterable, ESNext` | Browser and ESNext APIs |
148
+ | `isolatedModules` | `true` | File-level transpilation |
149
+ | `noEmit` | `true` | Lets the bundler handle output |
150
+ | `allowJs` | `true` | JavaScript file support |
151
+ | `resolveJsonModule` | `true` | JSON import support |
152
+ | `esModuleInterop` | `true` | CommonJS/ESM interop |
153
+ | `skipLibCheck` | `true` | Skip type checking of declaration files |
113
154
 
114
- - **Strict Type Checking**: Enables all strict options
115
- - **Modern JavaScript**: Targets ESNext with full ESNext lib support
116
- - **Module Resolution**: Node-style resolution with ESNext modules
117
- - **Developer Experience**: Force consistent casing, no unused variables/parameters
118
- - **JSON Support**: Resolve JSON modules
119
- - **Isolated Modules**: Transpile each file separately
155
+ ### Library Configuration Details
120
156
 
121
- ### Library Configuration Features
157
+ Extends `base.json` with:
122
158
 
123
- - **Declaration Generation**: Automatically generates `.d.ts` files
124
- - **Source Maps**: Generate source maps for debugging
125
- - **Strip Internal**: Remove internal declarations from output
126
- - **ESNext Only**: Does not include DOM libs
159
+ | Option | Value | Purpose |
160
+ | ------ | -------- | ------------------------------------------------------------- |
161
+ | `lib` | `ESNext` | No DOM libs -- library code should not depend on browser APIs |
127
162
 
128
- ### React Configuration Features
163
+ ### React Configuration Details
129
164
 
130
- - **Modern JSX Transform**: Uses `react-jsx` transform
131
- - **React Import Source**: Automatically import React when needed
132
- - **DOM Support**: Full DOM and DOM.Iterable libs
165
+ Extends `base.json` with:
133
166
 
134
- ### Next.js Configuration Features
167
+ | Option | Value | Purpose |
168
+ | ------ | ----------- | ----------------------------------------------- |
169
+ | `jsx` | `react-jsx` | Modern JSX transform (no `import React` needed) |
135
170
 
136
- - **JavaScript Support**: Allow `.js` files
137
- - **Incremental Compilation**: Faster subsequent builds
138
- - **JSX Preserve**: Let Next.js handle JSX transform
139
- - **Bundler Resolution**: Optimized for bundler
140
- - **No Emit**: Next.js handles compilation
141
- - **Next.js Plugin**: TypeScript plugin support
171
+ ### Next.js Configuration Details
172
+
173
+ Extends `base.json` with:
174
+
175
+ | Option | Value | Purpose |
176
+ | ------------- | ---------------------- | ------------------------------------- |
177
+ | `incremental` | `true` | Faster subsequent builds |
178
+ | `jsx` | `preserve` | Let Next.js handle JSX transformation |
179
+ | `plugins` | `[{ "name": "next" }]` | Next.js TypeScript plugin |
142
180
 
143
181
  ## API Reference
144
182
 
145
- ### Configuration Files
146
-
147
- #### `base.json`
148
-
149
- Base configuration with essential compiler options:
150
-
151
- ```typescript
152
- interface BaseConfig {
153
- compilerOptions: {
154
- allowSyntheticDefaultImports: true;
155
- declaration: true;
156
- esModuleInterop: true;
157
- forceConsistentCasingInFileNames: true;
158
- isolatedModules: true;
159
- lib: ["DOM", "DOM.Iterable", "ESNext"];
160
- module: "ESNext";
161
- moduleDetection: "force";
162
- moduleResolution: "node";
163
- noEmitOnError: true;
164
- noFallthroughCasesInSwitch: true;
165
- noImplicitOverride: true;
166
- noImplicitReturns: true;
167
- noUnusedLocals: true;
168
- noUnusedParameters: true;
169
- resolveJsonModule: true;
170
- skipLibCheck: true;
171
- strict: true;
172
- target: "ESNext";
173
- useDefineForClassFields: true;
174
- };
183
+ ### base.json
184
+
185
+ ```json
186
+ {
187
+ "compilerOptions": {
188
+ "allowJs": true,
189
+ "esModuleInterop": true,
190
+ "isolatedModules": true,
191
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
192
+ "module": "ESNext",
193
+ "moduleResolution": "bundler",
194
+ "noEmit": true,
195
+ "resolveJsonModule": true,
196
+ "skipLibCheck": true,
197
+ "strict": true,
198
+ "target": "ESNext"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ### library.json
204
+
205
+ ```json
206
+ {
207
+ "extends": "./base.json",
208
+ "compilerOptions": {
209
+ "lib": ["ESNext"]
210
+ }
175
211
  }
176
212
  ```
177
213
 
178
- #### `library.json`
214
+ ### react.json
215
+
216
+ ```json
217
+ {
218
+ "extends": "./base.json",
219
+ "compilerOptions": {
220
+ "jsx": "react-jsx"
221
+ }
222
+ }
223
+ ```
179
224
 
180
- Library-specific configuration extending base:
225
+ ### next.json
181
226
 
182
- ```typescript
183
- interface LibraryConfig extends BaseConfig {
184
- compilerOptions: BaseConfig["compilerOptions"] & {
185
- declaration: true;
186
- lib: ["ESNext"];
187
- sourceMap: true;
188
- stripInternal: true;
189
- };
227
+ ```json
228
+ {
229
+ "extends": "./base.json",
230
+ "compilerOptions": {
231
+ "incremental": true,
232
+ "jsx": "preserve",
233
+ "plugins": [{ "name": "next" }]
234
+ }
190
235
  }
191
236
  ```
192
237
 
193
- #### `react.json`
238
+ ## Compatibility
239
+
240
+ | Technology | Minimum Version | Notes |
241
+ | ---------- | --------------- | ------------------------------------ |
242
+ | TypeScript | 5.0.0 | Required |
243
+ | Node.js | 24.0.0 | Required |
244
+ | React | 18.0.0+ | When using `react.json` |
245
+ | Next.js | 14.0.0+ | When using `next.json` |
246
+ | Vite | 5.0.0+ | Works with bundler module resolution |
247
+ | Turbopack | Any | Works with bundler module resolution |
248
+ | esbuild | 0.19+ | Works with bundler module resolution |
249
+
250
+ ## Troubleshooting
251
+
252
+ ### Cannot find module or type declarations
253
+
254
+ When extending from `@codefast/typescript-config`, make sure the package is installed as a dev dependency and your `tsconfig.json` is at the project root:
255
+
256
+ ```bash
257
+ pnpm add -D @codefast/typescript-config
258
+ ```
259
+
260
+ ### Conflicting `lib` settings
194
261
 
195
- React-specific configuration:
262
+ If you need DOM types in a library project, override the `lib` option in your local `tsconfig.json`:
196
263
 
197
- ```typescript
198
- interface ReactConfig extends BaseConfig {
199
- compilerOptions: BaseConfig["compilerOptions"] & {
200
- jsx: "react-jsx";
201
- jsxImportSource: "react";
202
- };
264
+ ```json
265
+ {
266
+ "extends": "@codefast/typescript-config/library.json",
267
+ "compilerOptions": {
268
+ "lib": ["DOM", "DOM.Iterable", "ESNext"]
269
+ }
203
270
  }
204
271
  ```
205
272
 
206
- #### `next.json`
273
+ ### Path aliases not resolving
207
274
 
208
- Next.js-specific configuration:
275
+ When using path aliases, add them to both `tsconfig.json` and your bundler configuration:
209
276
 
210
- ```typescript
211
- interface NextConfig extends BaseConfig {
212
- compilerOptions: BaseConfig["compilerOptions"] & {
213
- allowJs: true;
214
- incremental: true;
215
- jsx: "preserve";
216
- moduleResolution: "bundler";
217
- noEmit: true;
218
- plugins: [{ name: "next" }];
219
- };
277
+ ```json
278
+ {
279
+ "extends": "@codefast/typescript-config/base.json",
280
+ "compilerOptions": {
281
+ "baseUrl": ".",
282
+ "paths": {
283
+ "@/*": ["./src/*"]
284
+ }
285
+ }
220
286
  }
221
287
  ```
222
288
 
223
- ## Contributing
289
+ ### Incremental build issues with Next.js
224
290
 
225
- We welcome all contributions! To start developing:
291
+ If you encounter stale type errors, delete the `.tsbuildinfo` file and rebuild:
226
292
 
227
- ### Environment Setup
293
+ ```bash
294
+ rm -f tsconfig.tsbuildinfo
295
+ pnpm build
296
+ ```
297
+
298
+ ## Contributing
228
299
 
229
- 1. Fork this repository.
230
- 2. Clone to your machine: `git clone <your-fork-url>`
231
- 3. Install dependencies: `pnpm install`
232
- 4. Create a new branch: `git checkout -b feature/feature-name`
300
+ We welcome contributions! Please see the [contributing guide](../../README.md#contributing) in the root of this repository for detailed instructions.
233
301
 
234
- ### Development Workflow
302
+ For package-specific development:
235
303
 
236
304
  ```bash
237
305
  # Build all packages
238
306
  pnpm build:packages
239
307
 
240
- # Development mode for typescript-config
241
- pnpm dev --filter=@codefast/typescript-config
242
-
243
- # Run tests
244
- pnpm test --filter=@codefast/typescript-config
245
-
246
- # Lint and format
247
- pnpm lint:fix
308
+ # Lint and format (from repo root)
309
+ pnpm lint
248
310
  pnpm format
249
311
  ```
250
312
 
251
- 5. Commit and submit pull request.
252
-
253
313
  ## License
254
314
 
255
- Distributed under the MIT License. See [LICENSE](../../LICENSE) for more information.
256
-
257
- ## Contact
258
-
259
- - npm: [@codefast/typescript-config](https://www.npmjs.com/package/@codefast/typescript-config)
260
- - GitHub: [codefastlabs/codefast](https://github.com/codefastlabs/codefast)
261
- - Issues: [GitHub Issues](https://github.com/codefastlabs/codefast/issues)
262
- - Documentation: [TypeScript Config Docs](https://github.com/codefastlabs/codefast/tree/main/packages/typescript-config)
263
-
264
- ## Compatibility
315
+ Distributed under the MIT License. See [LICENSE](../../LICENSE) for more details.
265
316
 
266
- This package is compatible with:
317
+ ## Changelog
267
318
 
268
- - **TypeScript**: 5.0.0+
269
- - **Node.js**: 20.0.0+
270
- - **React**: 18.0.0+ (when using react.json)
271
- - **Next.js**: 14.0.0+ (when using next.json)
319
+ See [CHANGELOG.md](./CHANGELOG.md) for a complete list of changes and version history.
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
1
  {
2
2
  "name": "@codefast/typescript-config",
3
- "version": "0.3.10",
3
+ "version": "0.3.11-canary.0",
4
4
  "description": "Shared TypeScript configuration for the monorepo",
5
5
  "keywords": [
6
- "typescript",
7
- "tsconfig",
6
+ "browser",
8
7
  "configuration",
8
+ "library",
9
9
  "monorepo",
10
- "react",
11
10
  "next",
12
11
  "node",
13
- "browser",
14
- "library"
12
+ "react",
13
+ "tsconfig",
14
+ "typescript"
15
15
  ],
16
16
  "homepage": "https://github.com/codefastlabs/codefast/tree/main/packages/typescript-config#readme",
17
17
  "bugs": {
18
18
  "url": "https://github.com/codefastlabs/codefast/issues"
19
19
  },
20
+ "license": "MIT",
21
+ "author": "Vuong Phan <mr.thevuong@gmail.com>",
20
22
  "repository": {
21
23
  "type": "git",
22
24
  "url": "git+https://github.com/codefastlabs/codefast.git",
23
25
  "directory": "packages/typescript-config"
24
26
  },
25
- "license": "MIT",
26
- "author": "Vuong Phan <mr.thevuong@gmail.com>",
27
- "exports": {
28
- "./base.json": "./base.json",
29
- "./library.json": "./library.json",
30
- "./next.json": "./next.json",
31
- "./react.json": "./react.json"
32
- },
33
27
  "files": [
34
28
  "*.json",
35
29
  "CHANGELOG.md",
36
30
  "README.md",
37
31
  "LICENSE"
38
32
  ],
33
+ "exports": {
34
+ "./base.json": "./base.json",
35
+ "./library.json": "./library.json",
36
+ "./next.json": "./next.json",
37
+ "./react.json": "./react.json"
38
+ },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  }