@codecompose/typescript-config 2.3.0 → 3.0.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.
- package/README.md +48 -16
- package/package.json +11 -3
- package/src/base.json +0 -4
package/README.md
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# typescript-config
|
|
2
2
|
|
|
3
|
-
Opinionated and reusable
|
|
3
|
+
Opinionated and reusable TypeScript configurations, geared towards modern build tooling in both monorepos and single repositories.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
5
|
+
- Uses the TypeScript compiler for type-checking only (*)
|
|
6
|
+
- Assumes your bundler outputs code, sourcemaps, and type declarations (*)
|
|
7
|
+
- Requires TypeScript 6.0 or later
|
|
8
|
+
- Builds on TS6 strict defaults with additional strictness: `noUncheckedIndexedAccess`, `noImplicitOverride`, and `erasableSyntaxOnly`
|
|
9
|
+
- Assumes `src` and `dist` directories
|
|
10
|
+
- Provides `~/` and `@/` path aliases for `src`
|
|
11
|
+
- Uses `${configDir}` for zero per-project configuration
|
|
11
12
|
|
|
12
|
-
(*)
|
|
13
|
+
(*) The shared-library and shared-react-library configs are an exception: they enable `composite`, `declaration`, and `declarationMap` because project references require TypeScript to emit declarations. Your bundler still handles the JavaScript output.
|
|
13
14
|
|
|
14
|
-
To use this successfully, you would need a modern bundler like [tsdown](https://tsdown.dev/). You can check out the [
|
|
15
|
+
To use this successfully, you would need a modern bundler like [tsdown](https://tsdown.dev/). You can check out the [typescript-monorepo](https://github.com/0x80/typescript-monorepo) boilerplate for a working example of a modern monorepo setup with tsdown.
|
|
16
|
+
|
|
17
|
+
These configurations are also compatible with [TSGo](https://github.com/nicksrandall/tsgo), the native Go port of the TypeScript compiler.
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
## Install
|
|
@@ -30,7 +33,7 @@ Often, no configuration is needed apart from `extends`.
|
|
|
30
33
|
|
|
31
34
|
## Available Configurations
|
|
32
35
|
|
|
33
|
-
- `base` -
|
|
36
|
+
- `base` - Anything non-specific
|
|
34
37
|
- `library` - Standalone libraries (not part of a monorepo)
|
|
35
38
|
- `shared-library` - Shared libraries in a monorepo
|
|
36
39
|
- `react-library` - Standalone React component libraries (not part of a monorepo)
|
|
@@ -41,10 +44,39 @@ Often, no configuration is needed apart from `extends`.
|
|
|
41
44
|
|
|
42
45
|
For other project types, like a CLI or E2E app, you can use the `base` configuration.
|
|
43
46
|
|
|
44
|
-
##
|
|
47
|
+
## V3 — TypeScript 6
|
|
48
|
+
|
|
49
|
+
V3 is a major release that requires TypeScript 6.0 or later.
|
|
50
|
+
|
|
51
|
+
TypeScript 6 aligns its defaults with the strict-by-default philosophy that this package has always followed. As a result, the base config is now leaner — options that are now TS6 defaults (`strict`, `esModuleInterop`) have been removed, and `isolatedModules` was dropped since it is implied by `verbatimModuleSyntax`.
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
TS6 also defaults `types` to `[]`, meaning `@types/*` packages are no longer auto-included. If your project depends on ambient type packages, you need to explicitly add them to your tsconfig:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"extends": "@codecompose/typescript-config/base",
|
|
58
|
+
"compilerOptions": {
|
|
59
|
+
"types": ["node"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This aligns with the strict-by-default philosophy — type dependencies should be explicit.
|
|
65
|
+
|
|
66
|
+
For users upgrading from v2, see the migration guide below.
|
|
67
|
+
|
|
68
|
+
## Migrating from v2
|
|
69
|
+
|
|
70
|
+
- **TypeScript 6 is required** — there is no backward compatibility with TS5
|
|
71
|
+
- **Removed `strict: true`** — now a TS6 default
|
|
72
|
+
- **Removed `esModuleInterop: true`** — safe interop behavior is always on in TS6
|
|
73
|
+
- **Removed `isolatedModules: true`** — implied by `verbatimModuleSyntax`
|
|
74
|
+
- **Removed commented-out `baseUrl`** — deprecated in TS6
|
|
75
|
+
- **Action required:** if you relied on auto-included `@types/*` packages, add `"types": ["node"]` (or whatever types you need) to your tsconfig
|
|
76
|
+
|
|
77
|
+
## Assuming Bundler Output
|
|
47
78
|
|
|
79
|
+
Outputs like sourcemaps and type declarations are disabled because it is assumed that your bundler will handle that. The shared-library and shared-react-library configs are an exception — they enable `declaration` and `declarationMap` because `composite` mode requires it for project references to work.
|
|
48
80
|
|
|
49
81
|
## Incremental Builds
|
|
50
82
|
|
|
@@ -57,7 +89,7 @@ recommend adding the following script to your manifest based on `del-cli`:
|
|
|
57
89
|
|
|
58
90
|
## Project References
|
|
59
91
|
|
|
60
|
-
The shared-library and shared-react-library configurations have `composite` set to `true`. This is required for
|
|
92
|
+
The shared-library and shared-react-library configurations have `composite` set to `true`. This is required for TypeScript "project references" to work in a monorepo. They provide IDE go-to-definition, without having to emit the module output.
|
|
61
93
|
|
|
62
94
|
In practice, this means that if you alter code in a shared package, the consuming app or library will pick up the changes, without requiring a watch task on the shared package to trigger a rebuild on every change.
|
|
63
95
|
|
|
@@ -67,13 +99,13 @@ If you prefer to work without project references, you should set your bundler to
|
|
|
67
99
|
|
|
68
100
|
## Publishing to NPM
|
|
69
101
|
|
|
70
|
-
If you publish your package, it is recommended to include the
|
|
102
|
+
If you publish your package, it is recommended to include the TypeScript source and type declaration maps. This allows the consumer to jump straight to the source code, which is great for overall readability and learning.
|
|
71
103
|
|
|
72
104
|
To export source files next to your dist output, you define the `files` field in your package.json as `["src", "dist"]`.
|
|
73
105
|
|
|
74
106
|
## Caveats
|
|
75
107
|
|
|
76
|
-
|
|
108
|
+
Next.js v15 requires you to explicitly configure `include`. If you give it just "src" it will inject its own types on startup. I assume this will improve in the future.
|
|
77
109
|
|
|
78
|
-
|
|
110
|
+
The base configuration includes `"${configDir}/src/**/*.json"` alongside `"${configDir}/src"` because TypeScript's `include` only picks up supported extensions (`.ts`, `.tsx`, etc.) when given a directory path. If you override `include` in your project tsconfig, make sure to keep the JSON glob if you import JSON files.
|
|
79
111
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecompose/typescript-config",
|
|
3
3
|
"description": "Opinionated reusable TypeScript configurations",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Thijs Koerselman",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/0x80/typescript-config"
|
|
10
|
+
},
|
|
7
11
|
"publishConfig": {
|
|
8
12
|
"access": "public"
|
|
9
13
|
},
|
|
@@ -31,5 +35,9 @@
|
|
|
31
35
|
"./shared-library": "./src/shared-library.json",
|
|
32
36
|
"./shared-react-library": "./src/shared-react-library.json"
|
|
33
37
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"typescript": ">=6.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {},
|
|
42
|
+
"packageManager": "pnpm@9.8.0"
|
|
43
|
+
}
|
package/src/base.json
CHANGED
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
"display": "Base configuration",
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
/* Base Options: */
|
|
6
|
-
"esModuleInterop": true,
|
|
7
6
|
"skipLibCheck": true,
|
|
8
7
|
"target": "esnext",
|
|
9
8
|
"lib": ["esnext"],
|
|
10
9
|
"allowJs": true,
|
|
11
10
|
"resolveJsonModule": true,
|
|
12
11
|
"moduleDetection": "force",
|
|
13
|
-
"isolatedModules": true,
|
|
14
12
|
"verbatimModuleSyntax": true,
|
|
15
13
|
|
|
16
14
|
/* Strictness */
|
|
17
|
-
"strict": true,
|
|
18
15
|
"noUncheckedIndexedAccess": true,
|
|
19
16
|
"noImplicitOverride": true,
|
|
20
17
|
"erasableSyntaxOnly": true,
|
|
@@ -24,7 +21,6 @@
|
|
|
24
21
|
"tsBuildInfoFile": "${configDir}/tsconfig.tsbuildinfo",
|
|
25
22
|
"module": "preserve",
|
|
26
23
|
"outDir": "${configDir}/dist",
|
|
27
|
-
// "baseUrl": "${configDir}",
|
|
28
24
|
"rootDir": "${configDir}/src",
|
|
29
25
|
"paths": {
|
|
30
26
|
"~/*": ["${configDir}/src/*"],
|