@vllnt/typescript 3.0.0-canary.f8310f4 → 3.0.1-canary.103ec2f

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 (4) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/README.md +254 -110
  3. package/llms.txt +46 -13
  4. package/package.json +22 -13
package/CHANGELOG.md CHANGED
@@ -2,7 +2,25 @@
2
2
 
3
3
  All notable changes to this project are documented in this file. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses semantic versioning.
4
4
 
5
- ## [Unreleased]
5
+ ## [3.0.1] - 2026-11-28
6
+
7
+ Presets are unchanged from 3.0.0, and so are the peer `typescript` range (`>=6.0.2 <8`) and `engines.node` (`>=22`). This release changes package metadata and the shipped documentation.
8
+
9
+ ### Added
10
+
11
+ - The README is rewritten for people and coding agents, with For coding agents, When to use, Install, Quick start, an API table of every export with each preset's own `compilerOptions`, Common tasks, Errors and fixes (code, message, cause and fix), Limits and gotchas, Compatibility, Related packages and Links. Links replaces the Documentation and support and Author sections.
12
+ - `llms.txt` is rewritten: summary, for coding agents, when to use, install, compatibility, every preset and the `./package.json` export, the inherited strictness flags, related packages, relative links to the shipped `README.md` and `CHANGELOG.md`, and an Ecosystem block.
13
+ - The README shows how to read the installed version (`require("@vllnt/typescript/package.json").version`), that paths outside the exports map fail with `ERR_PACKAGE_PATH_NOT_EXPORTED`, and that no preset sets `noEmitOnError`, so the presets that emit write output even when `tsc` reports type errors.
14
+
15
+ ### Changed
16
+
17
+ - `package.json`: `homepage` is https://oss.vllnt.com/packages/typescript, and `description` and `keywords` name what the package does and the stack.
18
+ - Repository tooling only (tests, CI, Privacy Guard, package-contents check, development and fixture dependency upgrades, pnpm 12.22.0), with no effect on the presets or the packed file list.
19
+
20
+ ### Fixed
21
+
22
+ - The README and `llms.txt` listed TS2322 for assigning `undefined` to an optional property under `exactOptionalPropertyTypes`; the code is TS2412.
23
+ - The README said that TypeScript 7 cannot disable strict mode. It can; with these presets, `strict: false` also needs `exactOptionalPropertyTypes: false` (TS5052).
6
24
 
7
25
  ## [3.0.0] - 2026-11-16
8
26
 
@@ -69,7 +87,8 @@ The flags add diagnostics and leave JavaScript output unchanged, but inferred de
69
87
  - Added `base.json`, `nodejs.json`, `node-library.json`, `react.json`, and `nextjs.json` presets.
70
88
  - Documented Node.js 22+ and TypeScript 5+ expectations.
71
89
 
72
- [Unreleased]: https://github.com/vllnt/typescript/compare/v2.0.1...HEAD
90
+ [3.0.1]: https://github.com/vllnt/typescript/compare/v3.0.0...v3.0.1
91
+ [3.0.0]: https://github.com/vllnt/typescript/compare/v2.0.1...v3.0.0
73
92
  [2.0.1]: https://github.com/vllnt/typescript/compare/v2.0.0...v2.0.1
74
93
  [2.0.0]: https://github.com/vllnt/typescript/compare/v1.0.0...v2.0.0
75
94
  [1.0.0]: https://github.com/vllnt/typescript/releases/tag/v1.0.0
package/README.md CHANGED
@@ -1,180 +1,312 @@
1
1
  # @vllnt/typescript
2
2
 
3
- Shared TypeScript configurations for Node.js, libraries, React, and Next.js. Version 2 targets the native TypeScript 7 compiler while retaining a tested TypeScript 6 migration path.
3
+ Shared tsconfig presets for Node.js apps, npm libraries, React and Next.js, with strict type-checking, tested with TypeScript 6 and 7.
4
4
 
5
- Use these independently in any project; no vllnt monorepo or runtime dependency
6
- is required. Extend a preset, then supply project-specific paths and ambient types.
5
+ ## For coding agents
7
6
 
8
- ## Install
7
+ These docs ship in `node_modules/@vllnt/typescript/` (`README.md`, `llms.txt`, `CHANGELOG.md`) and match the installed version. The package contains only JSON presets for `extends`; there is no JavaScript or type export to import.
8
+
9
+ ## When to use
9
10
 
10
- For TypeScript 7 projects:
11
+ - Use it when one `extends` line should set the compiler options of a Node.js app, an npm library, a bundled React app or a Next.js app.
12
+ - Use it when the project compiles with TypeScript 7, or with TypeScript 6.0.2 or newer.
13
+ - Do not use it on TypeScript 5 or older, or for ES5 output (TypeScript 7 removed `target: "ES5"`): use a `@tsconfig/*` preset made for your TypeScript version and runtime, such as `@tsconfig/node22`, or your own `tsconfig.json`.
14
+ - Do not use it when the code cannot pass `strict`: write your own `tsconfig.json`. If only the extra flags fail, turn them off one at a time (see [Common tasks](#turn-off-one-strictness-flag)).
15
+
16
+ ## Install
11
17
 
12
18
  ```sh
13
- pnpm add --save-dev @vllnt/typescript@^3 typescript@^7
19
+ pnpm add --save-dev @vllnt/typescript@^3 typescript@^7 @types/node@^22
14
20
  ```
15
21
 
16
- For tools that still require the TypeScript JavaScript API, install TypeScript 7 as the build compiler and TypeScript 6 under the canonical package name:
22
+ ## Quick start
23
+
24
+ A Node.js application with its sources in `src/`. `tsconfig.json`:
17
25
 
18
26
  ```json
19
27
  {
20
- "devDependencies": {
21
- "@typescript/native": "npm:typescript@^7.0.2",
22
- "@vllnt/typescript": "^3.0.0",
23
- "typescript": "npm:@typescript/typescript6@^6.0.2"
24
- }
28
+ "extends": "@vllnt/typescript/nodejs.json",
29
+ "compilerOptions": { "outDir": "dist", "rootDir": "src", "types": ["node"] },
30
+ "include": ["src"]
25
31
  }
26
32
  ```
27
33
 
28
- This is the [official side-by-side migration arrangement](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/): `tsc` runs TypeScript 7, `tsc6` runs TypeScript 6, and tools such as `typescript-eslint` can continue importing the TypeScript 6 API.
34
+ `src/index.ts`:
29
35
 
30
- ## Presets
36
+ ```ts
37
+ import { cwd } from "node:process";
31
38
 
32
- | Preset | Use case | Module resolution | Target | Emit |
33
- | ------------------- | ------------------------------------ | ----------------- | --------- | ------------------------------------- |
34
- | `base.json` | Foundation extended by other presets | Inherited | Inherited | Inherited |
35
- | `nodejs.json` | Node.js applications | NodeNext | ES2024 | JavaScript, declarations, source maps |
36
- | `node-library.json` | Publishable npm packages | NodeNext | ES2024 | JavaScript, declarations and maps |
37
- | `react.json` | Bundled React applications | Bundler | ES2022 | JavaScript, declarations, source maps |
38
- | `nextjs.json` | Next.js applications | Bundler | ES2022 | None |
39
+ export const directory: string = cwd();
40
+ ```
41
+
42
+ Run `pnpm exec tsc`. It writes `dist/index.js`, `dist/index.js.map` and `dist/index.d.ts`.
43
+
44
+ ## API
39
45
 
40
- Emitting presets do not enable `incremental`. Unless you opt in, a clean build emits every output even when a `.tsbuildinfo` file is left over. If you set `incremental: true`, delete the `.tsbuildinfo` file together with the output directory before a clean build. `nextjs.json` keeps `incremental` because it does not emit; if you override `noEmit`, also set `incremental: false`.
46
+ The package exports these files. Extend one preset per project; every preset extends `base.json`.
41
47
 
42
- ### Node.js application
48
+ | Export | Use for | Reference |
49
+ | ------------------------------------- | ----------------------------------------------------------- | -------------------------------------- |
50
+ | `@vllnt/typescript/base.json` | Strictness defaults only; you set `module`, `target`, `lib` | [base.json](#basejson) |
51
+ | `@vllnt/typescript/nodejs.json` | Node.js applications | [nodejs.json](#nodejsjson) |
52
+ | `@vllnt/typescript/node-library.json` | npm packages that publish JavaScript and declarations | [node-library.json](#node-libraryjson) |
53
+ | `@vllnt/typescript/react.json` | React applications built by a bundler such as Vite | [react.json](#reactjson) |
54
+ | `@vllnt/typescript/nextjs.json` | Next.js applications | [nextjs.json](#nextjsjson) |
55
+ | `@vllnt/typescript/package.json` | Reading the installed version from `.version` | [Compatibility](#compatibility) |
56
+
57
+ Each block below is the preset's own `compilerOptions`. Options you set after `extends` replace them; arrays such as `types` and `lib` are replaced, not merged.
58
+
59
+ ### base.json
43
60
 
44
61
  ```json
45
62
  {
46
- "extends": "@vllnt/typescript/nodejs.json",
47
- "compilerOptions": {
48
- "outDir": "dist",
49
- "rootDir": "src",
50
- "types": ["node"]
51
- },
52
- "include": ["src"]
63
+ "strict": true,
64
+ "esModuleInterop": true,
65
+ "forceConsistentCasingInFileNames": true,
66
+ "isolatedModules": true,
67
+ "skipLibCheck": true,
68
+ "noUncheckedIndexedAccess": true,
69
+ "noUncheckedSideEffectImports": true,
70
+ "noImplicitOverride": true,
71
+ "noImplicitReturns": true,
72
+ "noFallthroughCasesInSwitch": true,
73
+ "exactOptionalPropertyTypes": true,
74
+ "stableTypeOrdering": true,
75
+ "types": [],
76
+ "libReplacement": false,
77
+ "resolveJsonModule": true
78
+ }
79
+ ```
80
+
81
+ `types: []` loads no ambient `@types` package; list each one you need. `stableTypeOrdering` makes TypeScript 6 order types as TypeScript 7 does, and can make TypeScript 6 slower.
82
+
83
+ ### nodejs.json
84
+
85
+ ```json
86
+ {
87
+ "lib": ["ES2024"],
88
+ "module": "NodeNext",
89
+ "moduleResolution": "NodeNext",
90
+ "target": "ES2024",
91
+ "declaration": true,
92
+ "sourceMap": true
93
+ }
94
+ ```
95
+
96
+ ### node-library.json
97
+
98
+ ```json
99
+ {
100
+ "lib": ["ES2024"],
101
+ "module": "NodeNext",
102
+ "moduleResolution": "NodeNext",
103
+ "target": "ES2024",
104
+ "declaration": true,
105
+ "declarationMap": true,
106
+ "sourceMap": true
107
+ }
108
+ ```
109
+
110
+ ### react.json
111
+
112
+ ```json
113
+ {
114
+ "lib": ["DOM", "DOM.Iterable", "ES2024"],
115
+ "module": "ESNext",
116
+ "moduleResolution": "Bundler",
117
+ "target": "ES2022",
118
+ "jsx": "react-jsx",
119
+ "declaration": true,
120
+ "sourceMap": true
121
+ }
122
+ ```
123
+
124
+ ### nextjs.json
125
+
126
+ ```json
127
+ {
128
+ "lib": ["DOM", "DOM.Iterable", "ES2024"],
129
+ "module": "ESNext",
130
+ "moduleResolution": "Bundler",
131
+ "target": "ES2022",
132
+ "jsx": "preserve",
133
+ "noEmit": true,
134
+ "incremental": true,
135
+ "allowJs": true,
136
+ "plugins": [{ "name": "next" }]
53
137
  }
54
138
  ```
55
139
 
56
- ### Node library
140
+ ## Common tasks
141
+
142
+ ### Build an npm library
143
+
144
+ `tsconfig.json`:
57
145
 
58
146
  ```json
59
147
  {
60
148
  "extends": "@vllnt/typescript/node-library.json",
61
- "compilerOptions": {
62
- "outDir": "dist",
63
- "rootDir": "src",
64
- "types": ["node"]
65
- },
149
+ "compilerOptions": { "outDir": "dist", "rootDir": "src", "types": ["node"] },
66
150
  "include": ["src"]
67
151
  }
68
152
  ```
69
153
 
70
- ### React
154
+ The build writes `.js`, `.d.ts`, `.js.map` and `.d.ts.map` files. Without `"type": "module"` in `package.json`, NodeNext writes CommonJS.
155
+
156
+ ### Type-check a React app that Vite builds
157
+
158
+ `tsconfig.json`:
71
159
 
72
160
  ```json
73
161
  {
74
162
  "extends": "@vllnt/typescript/react.json",
75
- "compilerOptions": {
76
- "outDir": "dist",
77
- "rootDir": "src",
78
- "types": ["react"]
79
- },
163
+ "compilerOptions": { "noEmit": true, "types": ["react"] },
80
164
  "include": ["src"]
81
165
  }
82
166
  ```
83
167
 
84
- ### Next.js
168
+ `src/App.tsx`:
169
+
170
+ ```tsx
171
+ export function App() {
172
+ return <h1>Hello</h1>;
173
+ }
174
+ ```
175
+
176
+ To let `tsc` emit instead, replace `noEmit` with `"outDir": "dist"` and `"rootDir": "src"`.
177
+
178
+ ### Configure a Next.js app
179
+
180
+ `tsconfig.json`:
85
181
 
86
182
  ```json
87
183
  {
88
184
  "extends": "@vllnt/typescript/nextjs.json",
89
- "compilerOptions": {
90
- "types": ["node", "react"]
91
- },
185
+ "compilerOptions": { "types": ["node", "react"] },
92
186
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
93
187
  "exclude": ["node_modules"]
94
188
  }
95
189
  ```
96
190
 
97
- ## Base defaults
191
+ The integration test builds Next.js 16.4.6 with TypeScript 7.
98
192
 
99
- Every specialized preset inherits:
193
+ ### Keep TypeScript 6 for tools that need its JavaScript API
100
194
 
101
- - `strict: true`
102
- - `isolatedModules: true`
103
- - `noUncheckedIndexedAccess: true`
104
- - `noUncheckedSideEffectImports: true`
105
- - `noImplicitOverride: true`
106
- - `noImplicitReturns: true`
107
- - `noFallthroughCasesInSwitch: true`
108
- - `exactOptionalPropertyTypes: true`
109
- - `forceConsistentCasingInFileNames: true`
110
- - `skipLibCheck: true`
111
- - `esModuleInterop: true`
112
- - `resolveJsonModule: true`
113
- - `stableTypeOrdering: true`
114
- - `libReplacement: false`
115
- - `types: []`
195
+ `tsc` runs TypeScript 7 and `tsc6` runs TypeScript 6, so tools such as `typescript-eslint` can keep importing `typescript`. This is the [official side-by-side arrangement](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/). `package.json`:
116
196
 
117
- Ambient type packages are intentionally opt-in. List every required package in the consuming project's `types` array. Emitting projects must also set `rootDir` explicitly.
197
+ ```json
198
+ {
199
+ "devDependencies": {
200
+ "@typescript/native": "npm:typescript@^7.0.2",
201
+ "@vllnt/typescript": "^3.0.0",
202
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
203
+ }
204
+ }
205
+ ```
118
206
 
119
- `stableTypeOrdering` aligns TypeScript 6 output with TypeScript 7. It can make TypeScript 6 type-checking slower; TypeScript 7 always uses stable ordering.
207
+ ### Turn off one strictness flag
120
208
 
121
- ## Migrating from version 2
209
+ Set the flag after `extends`. `tsconfig.json`:
122
210
 
123
- Version 3 turns on four more flags in `base.json`, so every preset inherits them. Each one adds diagnostics, and none changes JavaScript output. `exactOptionalPropertyTypes` can change inferred declarations (see below). Run `tsc --noEmit` after upgrading and fix what it reports:
211
+ ```json
212
+ {
213
+ "extends": "@vllnt/typescript/nodejs.json",
214
+ "compilerOptions": {
215
+ "outDir": "dist",
216
+ "rootDir": "src",
217
+ "exactOptionalPropertyTypes": false
218
+ },
219
+ "include": ["src"]
220
+ }
221
+ ```
124
222
 
125
- | Flag | What it catches | Usual fix |
126
- | ---------------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
127
- | `noImplicitOverride` | A method that replaces a base-class method without saying so (TS4114) | Add the `override` modifier, or rename the method if it was not meant to replace the base one. |
128
- | `noImplicitReturns` | A function that returns a value on some paths and falls off the end on others (TS7030) | Add the missing `return` (`return undefined;` if that is intended). |
129
- | `noFallthroughCasesInSwitch` | A non-empty `case` that runs into the next one (TS7029) | End the case with `break`, `return` or `throw`. Empty cases that share a body are still allowed. |
130
- | `exactOptionalPropertyTypes` | Assigning `undefined` to a property declared `prop?: T` (TS2375, TS2379, TS2322) | Write `prop?: T \| undefined` if `undefined` is a valid value, or leave the key out when there is no value. |
223
+ ### Migrating from version 2
131
224
 
132
- `exactOptionalPropertyTypes` is the one most likely to need many edits. `prop?: T` now means "the key may be missing", not "the value may be undefined":
225
+ Version 3 turns on `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch` and `exactOptionalPropertyTypes` in `base.json`. They add diagnostics and leave JavaScript output unchanged. Run `tsc --noEmit` and fix what it reports; [Errors and fixes](#errors-and-fixes) lists each code. Under `exactOptionalPropertyTypes`, `prop?: T` means "the key may be missing", not "the value may be undefined". `src/options.ts`:
133
226
 
134
227
  ```ts
135
228
  interface Options {
136
229
  name?: string;
137
230
  }
138
231
 
139
- const a: Options = { name: undefined }; // error
140
- const b: Options = {}; // omit the key
232
+ export const a: Options = { name: undefined }; // error
233
+ export const b: Options = {};
141
234
 
142
- function build(name: string | undefined): Options {
143
- return name === undefined ? {} : { name }; // add the key only when it is set
235
+ export function build(name: string | undefined): Options {
236
+ return name === undefined ? {} : { name };
144
237
  }
145
238
  ```
146
239
 
147
- The same applies to call arguments and to props you pass to libraries: `use({ name: undefined })` is an error when the parameter's type does not list `undefined`. Widen your own types, or build the object without the key.
148
-
149
- `exactOptionalPropertyTypes` also changes declaration emit. When TypeScript infers a type that has an optional property, it now prints `count?: number` where it used to print `count?: number | undefined`. Types you annotate yourself are copied as written. If you publish a library, compare the `.d.ts` files before and after upgrading.
240
+ Inferred declarations can change: an optional property that version 2 emitted in declarations as `count?: number | undefined` is now emitted as `count?: number`. Libraries should compare their `.d.ts` output when upgrading. The [flag fixtures](https://github.com/vllnt/typescript/tree/main/tests/fixtures/flags) show a failing and an accepted form of each flag.
150
241
 
151
- To adopt the flags one at a time, set the ones you are not ready for to `false` in your own `compilerOptions` (after `extends`) and remove the override as you fix each one. The fixtures in `tests/fixtures/flags` show a failing and an accepted form of each pattern.
242
+ ### Migrating from version 1
152
243
 
153
- ## Migrating from version 1
154
-
155
- Version 2 supports TypeScript `>=6.0.2 <8` and drops TypeScript 5. Before upgrading:
244
+ Version 2 supports TypeScript `>=6.0.2 <8` and drops TypeScript 5:
156
245
 
157
246
  1. Remove `baseUrl` and make `paths` targets relative to the project root.
158
- 2. Replace legacy `moduleResolution: "node"` with `"NodeNext"` for Node.js or `"Bundler"` for bundled applications.
247
+ 2. Replace `moduleResolution: "node"` with `"NodeNext"` for Node.js or `"Bundler"` for bundled applications.
159
248
  3. Set `rootDir` in projects that emit files.
160
249
  4. List required ambient packages in `types`, such as `node` or `vitest/globals`.
161
- 5. Use Next.js 16.3 or newer when building with TypeScript 7.
162
- 6. Keep TypeScript 6 available through the side-by-side setup while ESLint or other tools require the legacy JavaScript API.
163
-
164
- TypeScript 7 also removes ES5 targeting, legacy module formats and resolution, `downlevelIteration`, and the ability to disable `esModuleInterop`, `allowSyntheticDefaultImports`, or strict mode.
250
+ 5. Use a Next.js release that builds with TypeScript 7; the integration test uses 16.4.6.
251
+ 6. Keep TypeScript 6 available side by side while ESLint or other tools require its JavaScript API.
252
+
253
+ ## Errors and fixes
254
+
255
+ The package runs no code and throws nothing. These are the compiler diagnostics that the presets cause or that commonly follow from them. `tests/docs.test.mjs` runs TypeScript 6 and 7 and reproduces each code with the compiler that reports it: the rows TS5102 / TS5101 and TS5108 / TS5107 give TypeScript 7's code first and TypeScript 6's second, and both compilers report every other code. It finds each message in the output of at least one of them.
256
+
257
+ | Code | Message contains | Cause | Fix |
258
+ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
259
+ | TS6053 | File '@vllnt/typescript/nodejs' not found | `extends` without `.json`, or the package is not installed (the message then names the specifier as written, such as `'@vllnt/typescript/nodejs.json'`) | Write the full export path, such as `@vllnt/typescript/nodejs.json`, and install the package |
260
+ | TS2591 | Cannot find name 'process'. Do you need to install type definitions for node? | `types: []` loads no `@types` package | Install `@types/node` and add `"node"` to `types` |
261
+ | TS5011 | The common source directory of 'tsconfig.json' is './src' | `outDir` without `rootDir` | Set `rootDir`, such as `"rootDir": "src"` |
262
+ | TS6059 | is not under 'rootDir' | `include` lists files outside `rootDir`, such as `tests/` next to `src/` | Type-check those files with a separate `tsconfig.json` that sets `noEmit`, or widen `rootDir` |
263
+ | TS2835 | Relative import paths need explicit file extensions in ECMAScript imports | NodeNext in a package with `"type": "module"` | Import `./file.js`, not `./file` |
264
+ | TS1309 | The current file is a CommonJS module and cannot use 'await' at the top level | Top-level `await` under NodeNext without `"type": "module"` | Add `"type": "module"` to `package.json`, or rename the file to `.mts` |
265
+ | TS5110 | Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext' | `module` overridden on `nodejs.json` or `node-library.json` | Override `module` and `moduleResolution` together, or extend `react.json` for bundled code |
266
+ | TS5109 / TS5095 | Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext' | `moduleResolution: "Bundler"` alone on `nodejs.json` or `node-library.json` | The same |
267
+ | TS5102 / TS5101 | Option 'baseUrl' has been removed / Option 'baseUrl' is deprecated | `baseUrl`, `downlevelIteration` or `outFile` in your `tsconfig.json` | Remove the option; make `paths` targets relative, and bundle instead of `outFile` |
268
+ | TS5108 / TS5107 | Option 'target=ES5' has been removed / Option 'target=ES5' is deprecated | A removed value: `target: "ES5"`, `moduleResolution: "node"` or `"classic"`, `esModuleInterop: false`, `allowSyntheticDefaultImports: false` | Remove the option, or use a supported value |
269
+ | TS5052 | Option 'exactOptionalPropertyTypes' cannot be specified without specifying option 'strictNullChecks' | `strict: false` (or `strictNullChecks: false`) while `exactOptionalPropertyTypes` is on | Also set `exactOptionalPropertyTypes: false` |
270
+ | TS17004 | Cannot use JSX unless the '--jsx' flag is provided | A `.tsx` file in a project on `nodejs.json`, `node-library.json` or `base.json` | Extend `react.json` or `nextjs.json`, or set `jsx` |
271
+ | TS2882 | Cannot find module or type declarations for side-effect import | `noUncheckedSideEffectImports` with an import such as `import "./styles.css"` | Fix the path, or declare the module, such as `declare module "*.css";`, or add `vite/client` to `types` |
272
+ | TS18048 / TS2532 | 'first' is possibly 'undefined' / Object is possibly 'undefined' | `noUncheckedIndexedAccess`: `array[0]` and `record[key]` have type `T \| undefined` | Check for `undefined` before use |
273
+ | TS4114 | This member must have an 'override' modifier | `noImplicitOverride` | Add `override` to the method, or rename it if it was not meant to replace the base method |
274
+ | TS7030 | Not all code paths return a value | `noImplicitReturns` | Return on every path, `return undefined;` if intended |
275
+ | TS7029 | Fallthrough case in switch | `noFallthroughCasesInSwitch` | End each non-empty `case` with `break`, `return` or `throw`; empty cases that share a body are allowed |
276
+ | TS2375 | Type '{ name: undefined; }' is not assignable to type 'Options' with 'exactOptionalPropertyTypes: true' | `exactOptionalPropertyTypes`: `undefined` given to `prop?: T` | Write `prop?: T \| undefined`, or leave the key out |
277
+ | TS2379 | Argument of type '{ name: undefined; }' is not assignable to parameter of type 'Options' with 'exactOptionalPropertyTypes: true' | The same, in a call argument | The same |
278
+ | TS2412 | Type 'undefined' is not assignable to type 'string' with 'exactOptionalPropertyTypes: true' | The same, in an assignment such as `options.name = undefined` | The same, or `delete options.name` |
279
+
280
+ ## Limits and gotchas
281
+
282
+ - The presets set no `outDir`, `rootDir`, `paths`, `include` or `files`. TypeScript resolves those relative to the file that sets them, so set them in your own `tsconfig.json`.
283
+ - `extends` must name an exported path with `.json`; `@vllnt/typescript/nodejs` fails with TS6053.
284
+ - `nodejs.json` and `node-library.json` use NodeNext: the nearest `package.json` `"type"` decides between ESM and CommonJS output for `.ts` files (`.mts` is always ESM, `.cts` always CommonJS), and ESM needs file extensions in relative imports.
285
+ - Emitting presets do not enable `incremental`, so a clean build emits every file even when a `.tsbuildinfo` is left over. If you set `incremental: true`, delete the `.tsbuildinfo` with the output directory before a clean build.
286
+ - `nextjs.json` keeps `incremental` because it sets `noEmit`. If you override `noEmit`, also set `incremental: false`.
287
+ - The `next` plugin in `nextjs.json` is an editor language-service plugin. `tsc` ignores it, and TypeScript 7 `--showConfig` leaves it out.
288
+ - No preset sets `noEmitOnError`, so the presets that emit (all but `nextjs.json`) still write output when `tsc` reports type errors. Set `noEmitOnError: true` to write nothing then.
289
+ - `skipLibCheck: true` skips type errors inside `.d.ts` files, including those of dependencies.
290
+ - `strict: false` alone fails with TS5052, because `exactOptionalPropertyTypes` needs `strictNullChecks`. Also set `exactOptionalPropertyTypes: false`.
291
+ - TypeScript 7 removed `target: "ES5"`, `moduleResolution: "node"` and `"classic"`, `esModuleInterop: false`, `allowSyntheticDefaultImports: false` (TS5108), and `baseUrl`, `downlevelIteration` and `outFile` (TS5102). TypeScript 6 reports them as deprecated.
292
+ - Under `exactOptionalPropertyTypes`, an optional property whose type is inferred, which version 2 emitted in declarations as `count?: number | undefined`, is now emitted as `count?: number`. Types you annotate yourself are copied as written, so a written `count?: number | undefined` keeps `undefined`.
293
+ - Install the `@types/node` major that matches your Node.js runtime; 22 is the oldest supported.
165
294
 
166
295
  ## Compatibility
167
296
 
168
- | Surface | Supported version |
169
- | ---------------------- | ------------------------------------------------------- |
170
- | Node.js consumers | `>=22` |
171
- | TypeScript | `>=6.0.2 <8` |
172
- | Tested compilers | TypeScript 6 compatibility package and TypeScript 7.0.2 |
173
- | Next.js integration | 16.4.5 |
174
- | React integration | 19.3.1 |
175
- | Repository development | Node.js 22.13+, pnpm 11.28.8 |
297
+ | Surface | Supported version |
298
+ | ---------------------- | -------------------------------------------------------------------------------- |
299
+ | TypeScript (peer) | `>=6.0.2 <8` |
300
+ | Node.js consumers | `>=22` |
301
+ | Tested compilers | TypeScript 7.0.2, and `@typescript/typescript6` 6.0.2 (its `tsc6` reports 6.0.3) |
302
+ | Next.js integration | 16.4.6 |
303
+ | React integration | 19.3.1 |
304
+ | Vite integration | 8.3.8 |
305
+ | Repository development | Node.js 22.13+, pnpm 12.22.0 |
306
+
307
+ The integration rows are the tested versions, not requirements. To print the installed version, run `node -p "require('@vllnt/typescript/package.json').version"`; paths missing from the API table, such as `@vllnt/typescript/README.md`, fail with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
176
308
 
177
- ## Development
309
+ ## Testing
178
310
 
179
311
  ```sh
180
312
  pnpm install --frozen-lockfile
@@ -182,7 +314,7 @@ pnpm check
182
314
  pnpm pack --dry-run
183
315
  ```
184
316
 
185
- The checks compile every preset with TypeScript 6 and 7, prove that each inherited strictness flag is active, verify declaration emit, install and compile the packed package, enforce full test-helper coverage, and build real React/Vite and Next.js fixtures.
317
+ The checks type-check the repository scripts and tests and compile every preset with TypeScript 6 and 7, prove that each strictness flag `base.json` enables besides `strict` raises its diagnostic in every preset and, in `base.json`, is its only cause (`strict` itself is checked with `--showConfig` and the TS5052 case), verify declaration emit, install and compile the packed package, check this README against the packed package, enforce full test-helper coverage, and build real React/Vite and Next.js fixtures.
186
318
 
187
319
  ## Versioning
188
320
 
@@ -191,21 +323,33 @@ The checks compile every preset with TypeScript 6 and 7, prove that each inherit
191
323
  - **Patch:** fixes, documentation, tests, or CI changes without consumer-visible behavior changes.
192
324
  - **Build-cache exception:** a patch may remove a build-cache default, such as `incremental`, that makes builds emit wrong or missing output. JavaScript, declaration, and source-map output of a clean build and all diagnostics must stay the same. The changelog states the cache effect and how to opt back in. 2.0.1 uses this exception.
193
325
 
194
- ## Documentation and support
326
+ npm `latest` is the newest stable release. `@canary` selects moving prereleases built from `main`; pin and test them before adoption. See the [changelog](CHANGELOG.md) and the [LLM index](llms.txt).
195
327
 
196
- - [LLM index](llms.txt) · [Changelog](CHANGELOG.md)
197
- - [Contributing](CONTRIBUTING.md) · [Issues](https://github.com/vllnt/typescript/issues)
198
- - [Security policy and private reporting](SECURITY.md)
328
+ ## Security
199
329
 
200
- npm `latest` is stable `3.0.0` at this audit. `@canary` selects moving prereleases;
201
- pin and test them before adoption. The compatibility matrix above describes
202
- this version's tested integrations, not a requirement to use every framework.
330
+ Report vulnerabilities privately as described in the [security policy](https://github.com/vllnt/typescript/blob/main/SECURITY.md).
203
331
 
204
- ## Author
332
+ ## Related packages
205
333
 
206
- Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com).
207
- Part of [@vllnt](https://github.com/vllnt). [Sponsor the work](https://github.com/sponsors/bntvllnt).
334
+ - [`@vllnt/eslint-config`](https://oss.vllnt.com/packages/eslint-config): ESLint presets for TypeScript projects. It sets lint rules and `@vllnt/typescript` sets compiler options; each is installed and configured on its own. This repository uses both: `eslint.config.mjs` imports `@vllnt/eslint-config/nodejs` (a devDependency) and lints the scripts and tests.
335
+
336
+ ## Contributing
337
+
338
+ See [CONTRIBUTING.md](https://github.com/vllnt/typescript/blob/main/CONTRIBUTING.md) and the [issues](https://github.com/vllnt/typescript/issues).
339
+
340
+ ## Links
341
+
342
+ - Docs and changelog: [oss.vllnt.com/packages/typescript](https://oss.vllnt.com/packages/typescript) · [release feed](https://oss.vllnt.com/packages/typescript/rss.xml)
343
+ - All @vllnt packages: [oss.vllnt.com](https://oss.vllnt.com) · [search packages and docs on index.vllnt.com](https://index.vllnt.com)
344
+ - Source and issues: [GitHub](https://github.com/vllnt/typescript) · [issues](https://github.com/vllnt/typescript/issues) · [npm](https://www.npmjs.com/package/@vllnt/typescript)
345
+ - Questions and updates: [Discord](https://bntvllnt.com/discord) · [X @bntvllnt](https://x.com/bntvllnt)
346
+ - Company and author: [vllnt.com](https://vllnt.com) · [bntvllnt.com](https://bntvllnt.com) · [GitHub @bntvllnt](https://github.com/bntvllnt) · [LinkedIn](https://linkedin.com/in/bntvllnt)
347
+ - Sponsor: [GitHub Sponsors](https://github.com/sponsors/bntvllnt)
208
348
 
209
349
  ## License
210
350
 
211
351
  [MIT](LICENSE)
352
+
353
+ ---
354
+
355
+ Part of [vllnt open source](https://oss.vllnt.com) · [Package page](https://oss.vllnt.com/packages/typescript) · [vllnt.com](https://vllnt.com) · Built by [bntvllnt](https://bntvllnt.com)
package/llms.txt CHANGED
@@ -1,16 +1,33 @@
1
1
  # @vllnt/typescript
2
2
 
3
- > Strict shared TypeScript presets for Node.js, libraries, React, and Next.js, tested with TypeScript 6 and the native TypeScript 7 compiler.
3
+ > Shared tsconfig presets for Node.js apps, npm libraries, React and Next.js, with strict type-checking, tested with TypeScript 6 and 7.
4
4
 
5
5
  - npm: https://www.npmjs.com/package/@vllnt/typescript
6
6
  - Repository: https://github.com/vllnt/typescript
7
- - Documentation: https://github.com/vllnt/typescript#readme
8
- - Changelog: https://github.com/vllnt/typescript/blob/main/CHANGELOG.md
7
+ - Documentation: [README](./README.md)
8
+ - API reference: [API](./README.md#api)
9
+ - Errors and fixes: [Errors and fixes](./README.md#errors-and-fixes)
10
+ - Changelog: [CHANGELOG](./CHANGELOG.md)
9
11
  - License: MIT
10
12
 
11
13
  Install independently in any project; no vllnt monorepo is required. npm latest
12
- is stable 3.0.0 at this audit; canary is a moving prerelease channel. Pin and test
13
- prereleases. See [Contributing](CONTRIBUTING.md) and the [Security policy](SECURITY.md).
14
+ is the newest stable release; canary is a moving prerelease channel built from main.
15
+ Pin and test prereleases. See [Contributing](https://github.com/vllnt/typescript/blob/main/CONTRIBUTING.md) and the [Security policy](https://github.com/vllnt/typescript/blob/main/SECURITY.md).
16
+
17
+ ## For coding agents
18
+
19
+ The documentation ships inside the package: `node_modules/@vllnt/typescript/` contains `README.md`, `llms.txt` and `CHANGELOG.md` next to the preset files, and they match the installed version. The package contains only JSON presets for `extends`; there is no JavaScript or type export to import.
20
+
21
+ ## When to use
22
+
23
+ - Use it when one `extends` line should set the compiler options of a Node.js app, an npm library, a bundled React app or a Next.js app.
24
+ - Use it when the project compiles with TypeScript 7, or with TypeScript 6.0.2 or newer.
25
+ - Do not use it on TypeScript 5 or older, or for ES5 output (TypeScript 7 removed `target: "ES5"`): use a `@tsconfig/*` preset made for your TypeScript version and runtime, such as `@tsconfig/node22`, or your own `tsconfig.json`.
26
+ - Do not use it when the code cannot pass `strict`: write your own `tsconfig.json`. If only the extra flags fail, turn them off one at a time in your own `compilerOptions`.
27
+
28
+ ## Install
29
+
30
+ `pnpm add --save-dev @vllnt/typescript@^3 typescript@^7 @types/node@^22`, then extend one preset, such as `"extends": "@vllnt/typescript/nodejs.json"`.
14
31
 
15
32
  ## Compatibility
16
33
 
@@ -21,24 +38,40 @@ prereleases. See [Contributing](CONTRIBUTING.md) and the [Security policy](SECUR
21
38
 
22
39
  ## Presets
23
40
 
24
- - `@vllnt/typescript/base.json`: strict shared defaults and explicit ambient types
25
- - `@vllnt/typescript/nodejs.json`: NodeNext Node.js applications targeting ES2024
26
- - `@vllnt/typescript/node-library.json`: publishable NodeNext libraries with declaration maps
27
- - `@vllnt/typescript/react.json`: bundled React applications using `react-jsx`
28
- - `@vllnt/typescript/nextjs.json`: no-emit Next.js applications
41
+ Extend one preset per project; every preset extends `base.json`. Full option lists: [API](./README.md#api).
42
+
43
+ - `@vllnt/typescript/base.json`: strict shared defaults and explicit ambient types; sets no `module`, `target` or `lib`
44
+ - `@vllnt/typescript/nodejs.json`: Node.js applications; NodeNext, ES2024, emits declarations and source maps
45
+ - `@vllnt/typescript/node-library.json`: publishable npm packages; as `nodejs.json` plus `declarationMap` (declaration maps)
46
+ - `@vllnt/typescript/react.json`: bundled React applications; ESNext with Bundler resolution, ES2022, DOM libs, `jsx: "react-jsx"`, emits declarations and source maps; set `noEmit: true` when a bundler such as Vite emits
47
+ - `@vllnt/typescript/nextjs.json`: Next.js applications; ESNext with Bundler resolution, ES2022, DOM libs, `jsx: "preserve"`, `noEmit`, `incremental`, `allowJs`, the `next` plugin
48
+ - `@vllnt/typescript/package.json`: not a preset; read the installed version with `require("@vllnt/typescript/package.json").version`
29
49
 
30
50
  Consumers should list required ambient packages in `types` and set `rootDir` in emitting projects.
31
51
  Emitting presets do not enable `incremental`, so a clean build emits every output even when a `.tsbuildinfo` file is left over. Projects that set `incremental: true` should delete the `.tsbuildinfo` file with the output directory before a clean build.
32
52
 
33
53
  ## Strictness inherited from base.json
34
54
 
35
- Every preset enables `strict`, `noUncheckedIndexedAccess`, `noUncheckedSideEffectImports`, `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch` and `exactOptionalPropertyTypes`.
55
+ Every preset enables `strict`, `noUncheckedIndexedAccess`, `noUncheckedSideEffectImports`, `noImplicitOverride`, `noImplicitReturns`, `noFallthroughCasesInSwitch` and `exactOptionalPropertyTypes`. The diagnostic codes and fixes are in [Errors and fixes](./README.md#errors-and-fixes).
36
56
 
37
57
  Migrating from version 2 (the last four flags are new):
38
58
 
39
59
  - `noImplicitOverride` (TS4114): add `override` to a method that replaces a base-class method.
40
60
  - `noImplicitReturns` (TS7030): return on every path; use `return undefined;` when that is intended.
41
61
  - `noFallthroughCasesInSwitch` (TS7029): end a non-empty `case` with `break`, `return` or `throw`.
42
- - `exactOptionalPropertyTypes` (TS2375, TS2379, TS2322): write `prop?: T | undefined` where `undefined` is a valid value, or omit the key.
43
- - JavaScript output does not change. Under `exactOptionalPropertyTypes`, inferred declarations can: `count?: number | undefined` is emitted as `count?: number`.
62
+ - `exactOptionalPropertyTypes` (TS2375, TS2379, TS2412): write `prop?: T | undefined` where `undefined` is a valid value, or omit the key.
63
+ - JavaScript output does not change. Under `exactOptionalPropertyTypes`, inferred declarations can: an optional property that version 2 emitted in declarations as `count?: number | undefined` is now emitted as `count?: number`. A type written as `number | undefined` keeps `undefined`.
44
64
  - To adopt them gradually, set a flag to `false` in the project's own `compilerOptions` after `extends`.
65
+
66
+ ## Related packages
67
+
68
+ - [@vllnt/eslint-config](https://oss.vllnt.com/packages/eslint-config): ESLint presets for TypeScript projects. It sets lint rules and these presets set compiler options; each is installed and configured on its own. This repository uses both: `eslint.config.mjs` imports `@vllnt/eslint-config/nodejs` (a devDependency) and lints the scripts and tests.
69
+
70
+ ## Ecosystem
71
+
72
+ - [Package page](https://oss.vllnt.com/packages/typescript)
73
+ - [Release feed](https://oss.vllnt.com/packages/typescript/rss.xml)
74
+ - [All @vllnt packages](https://oss.vllnt.com/llms.txt)
75
+ - [Search vllnt packages and docs](https://index.vllnt.com)
76
+ - [vllnt](https://vllnt.com/llms.txt)
77
+ - [Author](https://bntvllnt.com)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vllnt/typescript",
3
- "version": "3.0.0-canary.f8310f4",
4
- "description": "Shared TypeScript configurations for vllnt projects",
3
+ "version": "3.0.1-canary.103ec2f",
4
+ "description": "Shared tsconfig presets for Node.js apps, npm libraries, React and Next.js, with strict type-checking, tested with TypeScript 6 and 7.",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "bntvllnt",
@@ -11,7 +11,7 @@
11
11
  "type": "github",
12
12
  "url": "https://github.com/sponsors/bntvllnt"
13
13
  },
14
- "homepage": "https://github.com/vllnt/typescript#readme",
14
+ "homepage": "https://oss.vllnt.com/packages/typescript",
15
15
  "bugs": {
16
16
  "url": "https://github.com/vllnt/typescript/issues"
17
17
  },
@@ -22,10 +22,17 @@
22
22
  "keywords": [
23
23
  "typescript",
24
24
  "tsconfig",
25
- "config",
26
- "shared-config"
25
+ "tsconfig-base",
26
+ "typescript-config",
27
+ "shared-config",
28
+ "strict",
29
+ "nodejs",
30
+ "react",
31
+ "nextjs",
32
+ "vite",
33
+ "typescript-7"
27
34
  ],
28
- "packageManager": "pnpm@11.28.8",
35
+ "packageManager": "pnpm@12.22.0",
29
36
  "engines": {
30
37
  "node": ">=22"
31
38
  },
@@ -35,6 +42,7 @@
35
42
  "nodejs.json",
36
43
  "node-library.json",
37
44
  "react.json",
45
+ "README.md",
38
46
  "CHANGELOG.md",
39
47
  "llms.txt"
40
48
  ],
@@ -53,8 +61,10 @@
53
61
  "test": "vitest run",
54
62
  "test:coverage": "vitest run --coverage",
55
63
  "test:integration": "pnpm --dir tests/integration/react build && pnpm --dir tests/integration/nextjs build",
56
- "check": "pnpm format:check && pnpm lint && pnpm test:coverage && pnpm test:integration",
57
- "check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\""
64
+ "check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test:coverage && pnpm test:integration && pnpm test:package",
65
+ "check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\"",
66
+ "test:package": "bash scripts/test-check-package-contents.sh && bash scripts/check-package-contents.sh",
67
+ "typecheck": "tsc --project tsconfig.json && tsc6 --project tsconfig.json"
58
68
  },
59
69
  "peerDependencies": {
60
70
  "typescript": ">=6.0.2 <8"
@@ -62,14 +72,13 @@
62
72
  "devDependencies": {
63
73
  "@types/node": "22.20.5",
64
74
  "@types/react": "19.3.0",
65
- "@types/react-dom": "19.3.0",
66
75
  "@typescript/native": "npm:typescript@7.0.2",
67
- "@vitest/coverage-v8": "5.0.5",
68
- "@vllnt/eslint-config": "2.0.0",
76
+ "@vitest/coverage-v8": "5.1.1",
77
+ "@vllnt/eslint-config": "2.1.0",
69
78
  "eslint": "9.39.5",
70
- "prettier": "3.9.10",
79
+ "prettier": "3.10.1",
71
80
  "typescript": "npm:@typescript/typescript6@6.0.2",
72
- "vitest": "5.0.5"
81
+ "vitest": "5.1.1"
73
82
  },
74
83
  "publishConfig": {
75
84
  "access": "public",