@sarj/tsconfig 0.1.3 → 0.1.5

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 (2) hide show
  1. package/README.md +12 -121
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,128 +1,19 @@
1
- # @sarj/tsconfig
2
-
3
- Hyper-modern, maximally-strict TypeScript configs for sarj-ai projects.
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
-
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.
9
-
10
- ## Install
11
-
12
- ```bash
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
17
- ```
18
-
19
- ## Use
20
-
21
- `tsconfig.json` — the default for new projects:
22
-
23
- ```json
24
- {
25
- "extends": "@sarj/tsconfig/strict.json",
26
- "include": ["src/**/*"]
27
- }
28
- ```
29
-
30
- For libraries that need to be less strict (e.g. mid-migration), extend the base:
31
-
32
- ```json
33
- {
34
- "extends": "@sarj/tsconfig/base.json"
35
- }
36
- ```
37
-
38
- ## What's enabled
39
-
40
- ### `base.json` — modern defaults + first-party-parity strict-safety
41
-
42
- **Module / target (TS 6 + Node 24 LTS):**
1
+ <!-- Generated by `sarj-standards maintain docs sync`; do not edit. -->
43
2
 
44
- - `target: "ES2025"` / `lib: ["ES2025"]` — Iterator helpers, `Promise.try`, Set methods, `RegExp.escape`, Float16Array
45
- - `module: "NodeNext"` / `moduleResolution: "NodeNext"` — Node 24 native ESM resolution. **Override to `"preserve"` / `"bundler"` for Next.js / Vite / Vitest / esbuild consumers** (see rejection table)
46
- - `moduleDetection: "force"` — every file is a module; no accidental global scripts
47
- - `verbatimModuleSyntax: true` — `import type` required for type-only imports
48
- - `isolatedModules: true` — every file is a standalone compilation unit
49
- - `allowJs: false` — TS-only; no `.js` infiltration
50
- - `esModuleInterop` / `allowSyntheticDefaultImports`
51
- - `resolveJsonModule: true`
52
-
53
- **Type-safety hygiene (matches the first-party base config):**
54
-
55
- - `strict: true`
56
- - `noUncheckedIndexedAccess: true` — `arr[0]` is `T | undefined`
57
- - `noUncheckedSideEffectImports: true` (TS 5.6+)
58
- - `exactOptionalPropertyTypes: true`
59
- - `noImplicitOverride: true`
60
- - `noImplicitReturns: true`
61
- - `noFallthroughCasesInSwitch: true`
62
- - `noPropertyAccessFromIndexSignature: true` — bracket only for index signatures
63
- - `noUnusedLocals: true` / `noUnusedParameters: true`
64
- - `allowUnreachableCode: false` / `allowUnusedLabels: false`
65
- - `useDefineForClassFields: true`
66
-
67
- **Emit / publish:**
68
-
69
- - `declaration: true` / `declarationMap: true` / `sourceMap: true`
70
- - `newLine: "lf"` — reproducible cross-platform output
71
- - `stripInternal: true` — `@internal`-tagged declarations don't ship
72
- - `forceConsistentCasingInFileNames: true`
73
- - `skipLibCheck: true`
74
-
75
- ### `strict.json` — extends base + the hyper-strict flags
76
-
77
- - `isolatedDeclarations: true` (TS 5.5+) — forces explicit return types on every exported symbol; enables parallel `.d.ts` emit by `tsgo`/`swc`/`oxc`
78
- - `erasableSyntaxOnly: true` (TS 5.8+) — bans non-erasable syntax (enums, namespaces with values, parameter properties, `import =`); pairs with Node 24's `--experimental-strip-types`
79
- - `noErrorTruncation: true` — full type names in errors, no `...`
80
- - `strictBuiltinIteratorReturn: true` (TS 5.6+) — plugs the `any` leak in built-in iterators
81
- - All strict-family sub-flags explicitly listed (`alwaysStrict`, `noImplicitAny`, `noImplicitThis`, `strictBindCallApply`, `strictFunctionTypes`, `strictNullChecks`, `strictPropertyInitialization`, `useUnknownInCatchVariables`) — redundant with `strict: true` from base but pinned so future TS default flips can't loosen them
82
-
83
- ## What's NOT in the preset (and why)
84
-
85
- These were considered and explicitly rejected — they're per-project decisions, not shared-config concerns:
86
-
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):
3
+ # @sarj/tsconfig
108
4
 
109
- ```json
110
- {
111
- "extends": "@sarj/tsconfig/strict.json",
112
- "compilerOptions": {
113
- "isolatedDeclarations": false
114
- }
115
- }
116
- ```
5
+ Ultra-strict TypeScript configs for sarj-ai projects — strict.json + base.json
117
6
 
118
- ## Versioning
7
+ ## Package metadata
119
8
 
120
- Semver. Major-bump on TypeScript major releases (currently TS 6.x). The package ships with sigstore provenance (npm-attested).
9
+ | Field | Value |
10
+ | --- | --- |
11
+ | Version | `0.1.5` |
12
+ | Registry | npm |
13
+ | License | MIT |
121
14
 
122
- ## Influences
15
+ ## Project links
123
16
 
124
- These configs were authored by comparing against:
17
+ - [Homepage](https://code-standards.sarj.ai/cli/)
125
18
 
126
- - a first-party `tsconfig.base.json` (Next.js + lib monorepo baseline) and the `tsconfig.json` of its published integration SDK
127
- - `@tsconfig/strictest`, `@total-typescript/tsconfig`, `sindresorhus/tsconfig`, `@swan-io/tsconfig`, `vercel/style-guide`
128
- - TypeScript handbook strict-mode reference and the full TS 5.0 → 6.0 changelog
19
+ Package metadata is generated from [`package.json`](package.json).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/tsconfig",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "packageManager": "npm@11.19.0",
5
5
  "description": "Ultra-strict TypeScript configs for sarj-ai projects — strict.json + base.json",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "url": "git+https://github.com/sarj-ai/standards.git",
24
24
  "directory": "packages/tsconfig"
25
25
  },
26
- "homepage": "https://github.com/sarj-ai/standards/tree/main/packages/tsconfig",
26
+ "homepage": "https://code-standards.sarj.ai/cli/",
27
27
  "bugs": {
28
28
  "url": "https://github.com/sarj-ai/standards/issues"
29
29
  },