@alxwlw/tsconfig 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alxwlw
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 ADDED
@@ -0,0 +1,63 @@
1
+ # @alxwlw/tsconfig
2
+
3
+ TypeScript 7 `tsconfig` presets for the canon. Each preset is a plain `.json` file — extend it by
4
+ package specifier (published consumers) or by path (this repo, which extends its own presets
5
+ directly from `packages/tsconfig/`).
6
+
7
+ ## Presets
8
+
9
+ | Preset | Extends | Use it for |
10
+ | -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | `base.json` | — | Never extended directly by an app. Strict TS7 defaults every other preset builds on: `strict`, `noUncheckedIndexedAccess`, `verbatimModuleSyntax`, `declaration`. |
12
+ | `node.json` | `base` | A Node-targeted package or script. Adds `lib: ["ES2023"]` and `types: ["node"]`. |
13
+ | `library.json` | `base` | A package that ships compiled output for others to import. `emitDeclarationOnly` — types out, no `.js` (a bundler/`tsc -p` elsewhere produces the runtime file). |
14
+ | `react.json` | `base` | Browser/React code. `lib: ["ES2023", "DOM", "DOM.Iterable"]`, `jsx: "react-jsx"`, bundler resolution. |
15
+ | `refs.json` | `node` | A pnpm+moon **project-references** monorepo package: `composite`, `incremental`, emits only `.d.ts` into `.tsbuild/` — runtime JS comes from Bun/SWC/a bundler, not `tsc`. |
16
+ | `nest.json` | `refs` | A NestJS package on `refs.json`'s project-references discipline: legacy decorators + `emitDecoratorMetadata`, and `verbatimModuleSyntax: false` (DI needs the type import to survive erasure — see the preset's own comment). |
17
+ | `bun.json` | `base` | A Bun-native script or CLI (this repo's own `packages/stack` uses it): bundler resolution, `types: ["bun"]`, `noEmit`, `allowImportingTsExtensions`. |
18
+
19
+ ## Usage
20
+
21
+ ```jsonc
22
+ // tsconfig.json (repo root, or a package's own tsconfig)
23
+ {
24
+ "extends": "@alxwlw/tsconfig/node.json",
25
+ }
26
+ ```
27
+
28
+ None of these presets declare `@types/node` or `@types/bun` as a dependency of this package — **you
29
+ install the one(s) your `types` array needs yourself.** `node.json`/`refs.json`/`nest.json` expect
30
+ `@types/node` in your own `devDependencies`; `bun.json` (and any project whose tests use `bun:test`)
31
+ expects `@types/bun`. This package's own `devDependencies` on both are for running ITS tests
32
+ (`presets.test.ts` compiles a fixture per preset) — they are not re-exported to consumers, and pnpm's
33
+ strict linking will not hand them to you for free.
34
+
35
+ ## Sharp edge: `.ts`-extension imports and `bun:test` need more than `node.json`
36
+
37
+ If your source imports with an explicit `.ts` extension (`import { x } from './x.ts'` — required for
38
+ Bun/`nodenext` ESM to resolve at runtime without a build step) or your tests use `bun:test`, extending
39
+ `node.json` alone is **not enough** and will fail loudly:
40
+
41
+ ```
42
+ error TS5097: An import path can only end with '.ts' when 'allowImportingTsExtensions' is enabled.
43
+ ```
44
+
45
+ `allowImportingTsExtensions` requires `noEmit` (or `emitDeclarationOnly`) to be set — `node.json`
46
+ doesn't set either, because a plain Node package normally compiles its `.ts` to `.js` and does not
47
+ import by `.ts` extension. If your package is Bun-run and never emits, override on top:
48
+
49
+ ```jsonc
50
+ {
51
+ "extends": "@alxwlw/tsconfig/node.json",
52
+ "compilerOptions": {
53
+ "allowImportingTsExtensions": true,
54
+ "noEmit": true,
55
+ "types": ["node", "bun"],
56
+ },
57
+ }
58
+ ```
59
+
60
+ (This is exactly what this repo's own root `tsconfig.options.json` does — `bun.json` alone doesn't
61
+ fit either, since it drops `types: ["node"]`, which `node:*` built-in imports still need.) If you're
62
+ building a plain Bun CLI/script with no Node-specific typings, `bun.json` on its own is the simpler
63
+ fit — reach for the override above only when you need both surfaces at once.
package/base.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2022",
5
+ "module": "nodenext",
6
+ "moduleResolution": "nodenext",
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "declaration": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "verbatimModuleSyntax": true
14
+ }
15
+ }
package/bun.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ // Bun-runtime preset (standalone scripts/CLIs and Bun-native apps): bundler
4
+ // resolution, Bun type surface, no emit. allowImportingTsExtensions requires
5
+ // noEmit — and conflicts with composite project references (TS5096): repos
6
+ // on this preset should disable moon's syncProjectReferences. Validated
7
+ // against several production repos' hand-rolled equivalents.
8
+ "extends": "./base.json",
9
+ "compilerOptions": {
10
+ "module": "ESNext",
11
+ "moduleResolution": "bundler",
12
+ "lib": ["ES2023"],
13
+ "types": ["bun"],
14
+ "noEmit": true,
15
+ "declaration": false,
16
+ "allowImportingTsExtensions": true,
17
+ "isolatedModules": true,
18
+ "resolveJsonModule": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "noImplicitOverride": true,
21
+ "noImplicitReturns": true
22
+ }
23
+ }
package/library.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": { "declaration": true, "declarationMap": true, "emitDeclarationOnly": true }
4
+ }
package/nest.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ // NestJS preset = project-references discipline + legacy decorators.
4
+ // verbatimModuleSyntax MUST be false here: it elides type-only imports, and
5
+ // reflect-metadata DI resolves constructor params from those imports —
6
+ // eliding them yields UnknownDependenciesException at runtime while tsc and
7
+ // local dev pass. (This canon still requires explicit @Inject on every
8
+ // @Injectable ctor param — enforced by the oxlint canon's
9
+ // stack/require-nest-di-decorator rule.)
10
+ "extends": "./refs.json",
11
+ "compilerOptions": {
12
+ "experimentalDecorators": true,
13
+ "emitDecoratorMetadata": true,
14
+ "verbatimModuleSyntax": false
15
+ }
16
+ }
package/node.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": { "lib": ["ES2023"], "types": ["node"] }
4
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@alxwlw/tsconfig",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/alxwlw/stack.git"
8
+ },
9
+ "files": [
10
+ "*.json"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public",
14
+ "provenance": true
15
+ },
16
+ "devDependencies": {
17
+ "@types/bun": "catalog:dev",
18
+ "@types/node": "catalog:dev",
19
+ "typescript": "catalog:dev"
20
+ }
21
+ }
package/react.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": {
4
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
5
+ "jsx": "react-jsx",
6
+ "moduleResolution": "bundler",
7
+ "module": "esnext"
8
+ }
9
+ }
package/refs.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ // Project-references discipline for pnpm+moon monorepos (TS7-validated in
4
+ // production): tsc emits ONLY .d.ts into .tsbuild/ — runtime JS comes from
5
+ // Bun/SWC/bundlers. ${configDir} resolves against the EXTENDING config
6
+ // (TS 5.5+), so per-package tsconfigs usually need nothing beyond "extends".
7
+ "extends": "./node.json",
8
+ "compilerOptions": {
9
+ "target": "ES2023",
10
+ "lib": ["ES2023"],
11
+
12
+ "noFallthroughCasesInSwitch": true,
13
+ "noImplicitOverride": true,
14
+ "noImplicitReturns": true,
15
+
16
+ // Bun/SWC/esbuild transpile per-file — keep every file independently
17
+ // compilable; verbatimModuleSyntax is inherited true from base (the nest
18
+ // preset flips it off — decorator DI needs non-elided imports).
19
+ "isolatedModules": true,
20
+
21
+ "composite": true,
22
+ "declaration": true,
23
+ "declarationMap": true,
24
+ "emitDeclarationOnly": true,
25
+ "incremental": true,
26
+ "noEmitOnError": true,
27
+
28
+ "resolveJsonModule": true,
29
+
30
+ "rootDir": "${configDir}/src",
31
+ "outDir": "${configDir}/.tsbuild"
32
+ },
33
+ "include": ["${configDir}/src"],
34
+ "exclude": ["${configDir}/**/__tests__/**", "${configDir}/**/*.test.ts"]
35
+ }