@tractorbeam/typescript-config 0.4.0 → 0.5.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 CHANGED
@@ -1,6 +1,17 @@
1
1
  # @tractorbeam/typescript-config
2
2
 
3
- Shared `tsconfig` presets for Tractorbeam projects.
3
+ Shared `tsconfig` presets for Tractorbeam projects. A package's `tsconfig.json` extends one base preset, adds any add-ons, and lists only the files it checks:
4
+
5
+ ```json
6
+ {
7
+ "extends": [
8
+ "@tractorbeam/typescript-config/cloudflare-workers",
9
+ "@tractorbeam/typescript-config/effect",
10
+ "@tractorbeam/typescript-config/vitest"
11
+ ],
12
+ "include": ["src", "tests", "vitest.config.ts"]
13
+ }
14
+ ```
4
15
 
5
16
  ## Install
6
17
 
@@ -8,23 +19,31 @@ Shared `tsconfig` presets for Tractorbeam projects.
8
19
  pnpm add -D @tractorbeam/typescript-config
9
20
  ```
10
21
 
11
- ## Usage
22
+ Install the packages a preset names in `types`, such as `@types/node`, too.
12
23
 
13
- In your project’s `tsconfig.json`:
24
+ ## Base presets
14
25
 
15
- ```json
16
- {
17
- "extends": "@tractorbeam/typescript-config/node22.json"
18
- }
19
- ```
26
+ Extend exactly one.
27
+
28
+ The four bundler presets type-check code that a bundler or a type-stripping runner resolves. They emit nothing, preserve import syntax, allow `.ts` extensions in imports, and report unused locals and parameters. They share one `lib`, ES2023 with the DOM library for web-standard APIs such as `fetch` and `URL`, and differ only in the ambient `types` each environment needs:
29
+
30
+ | Preset | For | `types` |
31
+ | --- | --- | --- |
32
+ | `bundler` | Runtime-neutral libraries | none |
33
+ | `browser` | Browser code built with Vite, with its `vite.config.ts` | `node`, `vite/client` |
34
+ | `node-bundler` | Node code that a bundler builds | `node` |
35
+ | `cloudflare-workers` | Cloudflare Workers with `nodejs_compat` | `@cloudflare/workers-types`, `node` |
36
+
37
+ The other bases keep their own conventions:
38
+
39
+ - `node` and `node22`: Node code that `tsc` resolves with `nodenext`.
40
+ - `next`: Next.js.
41
+ - `tanstack-start`: TanStack Start.
42
+
43
+ ## Add-ons
20
44
 
21
- ## Presets
45
+ Add-ons go after the base in `extends` and set nothing a base sets, so they combine freely:
22
46
 
23
- - `@tractorbeam/typescript-config/node.json`
24
- - `@tractorbeam/typescript-config/node22.json`
25
- - `@tractorbeam/typescript-config/strictest.json`
26
- - `@tractorbeam/typescript-config/react.json`
27
- - `@tractorbeam/typescript-config/next.json`
28
- - `@tractorbeam/typescript-config/tanstack-start.json`
29
- - `@tractorbeam/typescript-config/vite.json`
30
- - `@tractorbeam/typescript-config/cloudflare-workers.json`
47
+ - `effect`: the Effect language service, with its diagnostics off.
48
+ - `vitest`: `import.meta.vitest` for in-source tests. It loads the types from a file, because a later preset's `types` would replace the base's instead of adding to them. Install `vitest` alongside it.
49
+ - `strictest`: the strictest checking flags.
package/browser.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["es2023", "esnext.disposable", "dom", "dom.iterable"],
5
+ "types": ["node", "vite/client"],
6
+ "target": "es2022",
7
+ "module": "preserve",
8
+ "moduleResolution": "bundler",
9
+ "jsx": "react-jsx",
10
+ "strict": true,
11
+ "noEmit": true,
12
+ "isolatedModules": true,
13
+ "esModuleInterop": true,
14
+ "resolveJsonModule": true,
15
+ "allowImportingTsExtensions": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "skipLibCheck": true
19
+ }
20
+ }
package/bundler.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["es2023", "esnext.disposable", "dom", "dom.iterable"],
5
+ "types": [],
6
+ "target": "es2022",
7
+ "module": "preserve",
8
+ "moduleResolution": "bundler",
9
+ "jsx": "react-jsx",
10
+ "strict": true,
11
+ "noEmit": true,
12
+ "isolatedModules": true,
13
+ "esModuleInterop": true,
14
+ "resolveJsonModule": true,
15
+ "allowImportingTsExtensions": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "skipLibCheck": true
19
+ }
20
+ }
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
- "target": "es2024",
5
- "lib": ["es2024"],
4
+ "lib": ["es2023", "esnext.disposable", "dom", "dom.iterable"],
5
+ "types": ["@cloudflare/workers-types", "node"],
6
+ "target": "es2022",
7
+ "module": "preserve",
8
+ "moduleResolution": "bundler",
6
9
  "jsx": "react-jsx",
7
- "module": "es2022",
8
- "moduleResolution": "Bundler",
9
- "resolveJsonModule": true,
10
- "allowJs": true,
11
- "checkJs": false,
10
+ "strict": true,
12
11
  "noEmit": true,
13
12
  "isolatedModules": true,
14
- "allowSyntheticDefaultImports": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "strict": true,
13
+ "esModuleInterop": true,
14
+ "resolveJsonModule": true,
15
+ "allowImportingTsExtensions": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
17
18
  "skipLibCheck": true
18
19
  }
19
20
  }
package/effect.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "plugins": [{ "name": "@effect/language-service", "diagnostics": false }]
5
+ }
6
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": ["es2023", "esnext.disposable", "dom", "dom.iterable"],
5
+ "types": ["node"],
6
+ "target": "es2022",
7
+ "module": "preserve",
8
+ "moduleResolution": "bundler",
9
+ "jsx": "react-jsx",
10
+ "strict": true,
11
+ "noEmit": true,
12
+ "isolatedModules": true,
13
+ "esModuleInterop": true,
14
+ "resolveJsonModule": true,
15
+ "allowImportingTsExtensions": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "skipLibCheck": true
19
+ }
20
+ }
package/node.json CHANGED
@@ -1,13 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "compilerOptions": {
4
- "lib": [
5
- "es2024",
6
- "ESNext.Array",
7
- "ESNext.Collection",
8
- "ESNext.Iterator",
9
- "ESNext.Promise"
10
- ],
4
+ "lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator", "ESNext.Promise"],
11
5
  "module": "nodenext",
12
6
  "target": "es2024",
13
7
  "strict": true,
package/package.json CHANGED
@@ -1,48 +1,60 @@
1
1
  {
2
2
  "name": "@tractorbeam/typescript-config",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Shared tsconfig presets for Tractorbeam projects",
5
5
  "keywords": [
6
+ "cloudflare-workers",
7
+ "effect",
8
+ "nextjs",
9
+ "tanstack",
6
10
  "tractorbeam",
7
11
  "tractorbeamai",
8
- "typescript",
9
12
  "tsconfig",
10
13
  "tsconfig-bases",
11
- "react",
12
- "nextjs",
13
- "vite",
14
- "tanstack"
14
+ "typescript",
15
+ "vitest"
15
16
  ],
16
17
  "homepage": "https://github.com/tractorbeamai/reusables/tree/main/packages/typescript-config#readme",
17
18
  "bugs": {
18
19
  "url": "https://github.com/tractorbeamai/reusables/issues"
19
20
  },
21
+ "license": "MIT",
20
22
  "repository": {
21
23
  "type": "git",
22
24
  "url": "git+https://github.com/tractorbeamai/reusables.git",
23
25
  "directory": "packages/typescript-config"
24
26
  },
25
- "license": "MIT",
27
+ "files": [
28
+ "*.json",
29
+ "*.ts",
30
+ "package.json",
31
+ "README.md"
32
+ ],
26
33
  "type": "module",
27
34
  "exports": {
35
+ "./bundler": "./bundler.json",
36
+ "./browser": "./browser.json",
37
+ "./node-bundler": "./node-bundler.json",
38
+ "./cloudflare-workers": "./cloudflare-workers.json",
28
39
  "./node": "./node.json",
29
40
  "./node22": "./node22.json",
30
- "./strictest": "./strictest.json",
31
- "./react": "./react.json",
32
41
  "./next": "./next.json",
33
42
  "./tanstack-start": "./tanstack-start.json",
34
- "./vite": "./vite.json",
35
- "./cloudflare-workers": "./cloudflare-workers.json",
43
+ "./effect": "./effect.json",
44
+ "./vitest": "./vitest.json",
45
+ "./strictest": "./strictest.json",
36
46
  "./presets": "./presets.ts"
37
47
  },
38
- "files": [
39
- "*.json",
40
- "*.ts",
41
- "package.json",
42
- "README.md"
43
- ],
44
48
  "publishConfig": {
45
49
  "access": "public",
46
50
  "provenance": true
51
+ },
52
+ "peerDependencies": {
53
+ "vitest": "*"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "vitest": {
57
+ "optional": true
58
+ }
47
59
  }
48
60
  }
package/presets.ts CHANGED
@@ -1,19 +1,25 @@
1
+ import browser from "./browser.json" with { type: "json" };
2
+ import bundler from "./bundler.json" with { type: "json" };
1
3
  import cloudflareWorkers from "./cloudflare-workers.json" with { type: "json" };
4
+ import effect from "./effect.json" with { type: "json" };
2
5
  import next from "./next.json" with { type: "json" };
3
6
  import node from "./node.json" with { type: "json" };
7
+ import nodeBundler from "./node-bundler.json" with { type: "json" };
4
8
  import node22 from "./node22.json" with { type: "json" };
5
- import react from "./react.json" with { type: "json" };
6
9
  import strictest from "./strictest.json" with { type: "json" };
7
10
  import tanstackStart from "./tanstack-start.json" with { type: "json" };
8
- import vite from "./vite.json" with { type: "json" };
11
+ import vitest from "./vitest.json" with { type: "json" };
9
12
 
10
- export const presets: Record<string, Record<string, unknown>> = {
13
+ export const presets = {
14
+ browser,
15
+ bundler,
11
16
  "cloudflare-workers": cloudflareWorkers,
17
+ effect,
12
18
  next,
13
19
  node,
20
+ "node-bundler": nodeBundler,
14
21
  node22,
15
- react,
16
22
  strictest,
17
23
  "tanstack-start": tanstackStart,
18
- vite,
24
+ vitest,
19
25
  };
package/vitest.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="vitest/importMeta" />
package/vitest.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "files": ["./vitest.d.ts"]
4
+ }
package/react.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "compilerOptions": {
4
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5
- "target": "ES2022",
6
- "useDefineForClassFields": true,
7
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
8
- "module": "ESNext",
9
- "skipLibCheck": true,
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
- "jsx": "react-jsx",
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "erasableSyntaxOnly": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true
22
- }
23
- }
package/vite.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "compilerOptions": {
4
- "target": "ES2020",
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "isolatedModules": true,
8
- "types": ["vite/client"],
9
- "skipLibCheck": true
10
- }
11
- }