@sarj/tsconfig 0.1.0 → 0.1.3
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/LICENSE +21 -0
- package/README.md +46 -29
- package/base.json +1 -3
- package/package.json +6 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sarj-ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# @sarj/tsconfig
|
|
2
2
|
|
|
3
3
|
Hyper-modern, maximally-strict TypeScript configs for sarj-ai projects.
|
|
4
|
-
|
|
4
|
+
Covers every type-safety flag in the flagship first-party monorepo's `tsconfig.base.json` and in its published integration SDK's `tsconfig.json`. Per-project flags (`composite`, `noEmit`, `outDir`, `jsx`, `types`) and bundler-specific module resolution are intentionally omitted — see [What's NOT in the preset](#whats-not-in-the-preset-and-why) below.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## Requires
|
|
7
|
+
|
|
8
|
+
- **TypeScript ≥ 6.0** — the configs use `target: "ES2025"`, `lib: ["ES2025"]`, `isolatedDeclarations`, `erasableSyntaxOnly`, and `strictBuiltinIteratorReturn`, all of which need TS 5.5+ at minimum and ES2025 needs TS 6.
|
|
7
9
|
|
|
8
10
|
## Install
|
|
9
11
|
|
|
10
12
|
```bash
|
|
11
|
-
npm
|
|
12
|
-
|
|
13
|
-
yarn add -D @sarj/tsconfig typescript
|
|
13
|
+
npm i -D @sarj/tsconfig typescript@^6
|
|
14
|
+
pnpm add -D @sarj/tsconfig typescript@^6
|
|
15
|
+
yarn add -D @sarj/tsconfig typescript@^6
|
|
16
|
+
bun add -d @sarj/tsconfig typescript@^6
|
|
14
17
|
```
|
|
15
18
|
|
|
16
19
|
## Use
|
|
@@ -34,12 +37,12 @@ For libraries that need to be less strict (e.g. mid-migration), extend the base:
|
|
|
34
37
|
|
|
35
38
|
## What's enabled
|
|
36
39
|
|
|
37
|
-
### `base.json` — modern defaults +
|
|
40
|
+
### `base.json` — modern defaults + first-party-parity strict-safety
|
|
38
41
|
|
|
39
42
|
**Module / target (TS 6 + Node 24 LTS):**
|
|
40
43
|
|
|
41
44
|
- `target: "ES2025"` / `lib: ["ES2025"]` — Iterator helpers, `Promise.try`, Set methods, `RegExp.escape`, Float16Array
|
|
42
|
-
- `module: "NodeNext"` / `moduleResolution: "NodeNext"` — Node 24 native ESM resolution
|
|
45
|
+
- `module: "NodeNext"` / `moduleResolution: "NodeNext"` — Node 24 native ESM resolution. **Override to `"preserve"` / `"bundler"` for Next.js / Vite / Vitest / esbuild consumers** (see rejection table)
|
|
43
46
|
- `moduleDetection: "force"` — every file is a module; no accidental global scripts
|
|
44
47
|
- `verbatimModuleSyntax: true` — `import type` required for type-only imports
|
|
45
48
|
- `isolatedModules: true` — every file is a standalone compilation unit
|
|
@@ -47,7 +50,7 @@ For libraries that need to be less strict (e.g. mid-migration), extend the base:
|
|
|
47
50
|
- `esModuleInterop` / `allowSyntheticDefaultImports`
|
|
48
51
|
- `resolveJsonModule: true`
|
|
49
52
|
|
|
50
|
-
**Type-safety hygiene (matches
|
|
53
|
+
**Type-safety hygiene (matches the first-party base config):**
|
|
51
54
|
|
|
52
55
|
- `strict: true`
|
|
53
56
|
- `noUncheckedIndexedAccess: true` — `arr[0]` is `T | undefined`
|
|
@@ -69,10 +72,6 @@ For libraries that need to be less strict (e.g. mid-migration), extend the base:
|
|
|
69
72
|
- `forceConsistentCasingInFileNames: true`
|
|
70
73
|
- `skipLibCheck: true`
|
|
71
74
|
|
|
72
|
-
**Misc:**
|
|
73
|
-
|
|
74
|
-
- `ignoreDeprecations: "6.0"` — silences TS 6.0 `baseUrl` warnings emitted by tools like tsup
|
|
75
|
-
|
|
76
75
|
### `strict.json` — extends base + the hyper-strict flags
|
|
77
76
|
|
|
78
77
|
- `isolatedDeclarations: true` (TS 5.5+) — forces explicit return types on every exported symbol; enables parallel `.d.ts` emit by `tsgo`/`swc`/`oxc`
|
|
@@ -85,27 +84,45 @@ For libraries that need to be less strict (e.g. mid-migration), extend the base:
|
|
|
85
84
|
|
|
86
85
|
These were considered and explicitly rejected — they're per-project decisions, not shared-config concerns:
|
|
87
86
|
|
|
88
|
-
| Flag | Why not in @sarj/tsconfig |
|
|
89
|
-
|
|
90
|
-
| `composite` / `incremental` | Per-project; depends on whether you use project references |
|
|
91
|
-
| `noEmit` | App-vs-lib; apps want `true`, libs want `false` |
|
|
92
|
-
| `outDir` / `rootDir` / `paths`
|
|
93
|
-
| `jsx` | Framework-specific
|
|
94
|
-
| `DOM` / `DOM.Iterable` in `lib` | Base is Node-safe; browser packages add DOM in their own tsconfig |
|
|
95
|
-
| `types` / `typeRoots` | Forces every consumer to enumerate ambient types — high friction |
|
|
96
|
-
|
|
|
97
|
-
| `
|
|
87
|
+
| Flag | Why not in @sarj/tsconfig | What to set in your own tsconfig |
|
|
88
|
+
|------|---------------------------|----------------------------------|
|
|
89
|
+
| `composite` / `incremental` | Per-project; depends on whether you use project references | Add to your tsconfig if you use `tsc -b` |
|
|
90
|
+
| `noEmit` | App-vs-lib; apps want `true`, libs want `false` | `true` for Next.js / Vite apps; omit for libs |
|
|
91
|
+
| `outDir` / `rootDir` / `paths` | Per-project layout | Set per package |
|
|
92
|
+
| `jsx` | Framework-specific | `"preserve"` for Next.js; `"react-jsx"` for plain React |
|
|
93
|
+
| `DOM` / `DOM.Iterable` / `DOM.AsyncIterable` in `lib` | Base is Node-safe; browser packages add DOM in their own tsconfig. **`lib` is a REPLACE field, not merge — you must include `ES2025` too.** | `"lib": ["ES2025", "DOM", "DOM.Iterable", "DOM.AsyncIterable"]` |
|
|
94
|
+
| `types` / `typeRoots` | Forces every consumer to enumerate ambient types — high friction | Add `["node", "vitest/globals"]` etc. per project |
|
|
95
|
+
| Bundler module resolution | NodeNext is correct for libraries; Next.js / Vite / esbuild prefer bundler | `"module": "preserve", "moduleResolution": "bundler"` |
|
|
96
|
+
| `noEmitOnError` | Breaks dev/editor partial-emit workflows; gate via separate `tsc --noEmit` in CI | — |
|
|
97
|
+
| `rewriteRelativeImportExtensions` / `allowImportingTsExtensions` | Per-runtime decision (depends on whether you run `.ts` directly) | Set if using `tsx` / Bun / Deno |
|
|
98
|
+
|
|
99
|
+
## Migration notes
|
|
100
|
+
|
|
101
|
+
Adopting `strict.json` on a brownfield codebase typically surfaces hundreds of errors. The three flags that produce the bulk:
|
|
102
|
+
|
|
103
|
+
- **`isolatedDeclarations`** (TS9007) — every exported function, class, and `const` needs an explicit return type. A multi-day sweep. Run `tsc --noEmit --isolatedDeclarations` first to see the scope.
|
|
104
|
+
- **`erasableSyntaxOnly`** — bans `enum`, `namespace { ... value ... }`, parameter properties (`constructor(private x: T)`), `import =`. Convert enums to `as const` literal unions; rewrite parameter properties as explicit field assignment.
|
|
105
|
+
- **`exactOptionalPropertyTypes`** — `{ x?: T }` no longer accepts `{ x: undefined }`. Either tighten the call sites to omit the key, or widen the type to `{ x?: T | undefined }`.
|
|
106
|
+
|
|
107
|
+
To opt out of a single flag from your tsconfig, just set it to `false` (it overrides the extended preset):
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"extends": "@sarj/tsconfig/strict.json",
|
|
112
|
+
"compilerOptions": {
|
|
113
|
+
"isolatedDeclarations": false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
98
117
|
|
|
99
118
|
## Versioning
|
|
100
119
|
|
|
101
|
-
Semver. Major-bump on TypeScript major releases (currently TS 6.x).
|
|
120
|
+
Semver. Major-bump on TypeScript major releases (currently TS 6.x). The package ships with sigstore provenance (npm-attested).
|
|
102
121
|
|
|
103
|
-
##
|
|
122
|
+
## Influences
|
|
104
123
|
|
|
105
|
-
These configs were authored
|
|
124
|
+
These configs were authored by comparing against:
|
|
106
125
|
|
|
107
|
-
-
|
|
108
|
-
- bulbul's `integration-client/tsconfig.json` (the published SDK strict reference)
|
|
126
|
+
- a first-party `tsconfig.base.json` (Next.js + lib monorepo baseline) and the `tsconfig.json` of its published integration SDK
|
|
109
127
|
- `@tsconfig/strictest`, `@total-typescript/tsconfig`, `sindresorhus/tsconfig`, `@swan-io/tsconfig`, `vercel/style-guide`
|
|
110
|
-
- TypeScript handbook strict-mode reference
|
|
111
|
-
- Every strict-related flag introduced from TS 5.0 → 6.0
|
|
128
|
+
- TypeScript handbook strict-mode reference and the full TS 5.0 → 6.0 changelog
|
package/base.json
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarj/tsconfig",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"packageManager": "npm@11.19.0",
|
|
4
5
|
"description": "Ultra-strict TypeScript configs for sarj-ai projects — strict.json + base.json",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"files": [
|
|
7
8
|
"strict.json",
|
|
8
9
|
"base.json",
|
|
10
|
+
"LICENSE",
|
|
9
11
|
"README.md"
|
|
10
12
|
],
|
|
11
13
|
"exports": {
|
|
12
14
|
"./strict.json": "./strict.json",
|
|
13
|
-
"./base.json": "./base.json"
|
|
15
|
+
"./base.json": "./base.json",
|
|
16
|
+
"./package.json": "./package.json"
|
|
14
17
|
},
|
|
15
18
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
"provenance": true
|
|
19
|
+
"access": "public"
|
|
18
20
|
},
|
|
19
21
|
"repository": {
|
|
20
22
|
"type": "git",
|
|
@@ -36,8 +38,5 @@
|
|
|
36
38
|
"license": "MIT",
|
|
37
39
|
"peerDependencies": {
|
|
38
40
|
"typescript": ">=6.0.0"
|
|
39
|
-
},
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=24.0.0"
|
|
42
41
|
}
|
|
43
42
|
}
|