@petbee/tsconfig 2.0.0 → 3.0.1

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,32 +1,53 @@
1
1
  # `@petbee/tsconfig`
2
2
 
3
- This is default `tsconfig.json` that should be used by all Petbee projects.
3
+ This is the default `tsconfig.json` that should be used by all Petbee projects.
4
+
5
+ ## Features (v3.0.0)
6
+
7
+ - ✅ **TypeScript 5.9+** - Modern TypeScript support
8
+ - ✅ **ES2022+ Target** - Modern JavaScript features
9
+ - ✅ **Modern Module Resolution** - `bundler` for web apps, `NodeNext` for Node.js
10
+ - ✅ **Strict Type Safety** - Including `noUncheckedIndexedAccess` for safer array access
11
+ - ✅ **Verbatim Module Syntax** - Better ESM compatibility
12
+ - ✅ **React 17+ JSX** - New JSX transform (`react-jsx`)
4
13
 
5
14
  ## Install
6
15
 
7
16
  ```bash
8
- yarn add -D @petbee/tsconfig
17
+ yarn add -D @petbee/tsconfig typescript
9
18
  ```
10
19
 
20
+ ## Module Resolution Guide
21
+
22
+
23
+ This package provides entry-point configs for each framework, making it easy to extend the right config for your project:
24
+
25
+ - **`base.json`** – Safe, strict defaults for all projects (modern web, library, etc.)
26
+ - **`react.json`** – For React projects (extends `react/dom.json`)
27
+ - **`node.json`** – For Node.js ESM projects (extends `node/base.json`)
28
+ - **`nestjs.json`** – For NestJS projects (extends `nestjs/base.json`)
29
+ - **`nextjs.json`** – For Next.js projects (extends `nextjs/base.json`)
30
+ - **`node/commonjs.json`** – For legacy Node.js CommonJS projects
31
+
32
+ You can also extend the more granular configs in each framework folder if you need a specific variant (e.g., `react/library.json`, `node/library.json`).
33
+
11
34
  ## Usage
12
35
 
13
36
  ### React Project
14
37
 
15
- #### React Application Project
16
38
 
17
- To start, create a `tsconfig.json` in the root of your project.
39
+ #### React Project
18
40
 
19
- A typical setup where the application sit in `[project root]/app` folder is as follow:
41
+ To start, create a `tsconfig.json` in the root of your project:
20
42
 
21
43
  ```json
22
44
  {
23
- "extends": "@petbee/tsconfig/react/application.json",
45
+ "extends": "@petbee/tsconfig/react.json",
24
46
  "compilerOptions": {
25
47
  "baseUrl": ".",
26
- "rootDir": ".",
27
- "paths": { "*": ["*", "app/*"] }
48
+ "rootDir": "."
28
49
  },
29
- "include": ["./app/**/*", "./client/**/*", "./server/**/*", "./tests/**/*"]
50
+ "include": ["./src/**/*"]
30
51
  }
31
52
  ```
32
53
 
@@ -47,7 +68,9 @@ Similarly for a react library project. Create a `tsconfig.json` in the root of y
47
68
 
48
69
  #### Project that run in the browser
49
70
 
50
- A configuration file is provided that included styles setup and a more conservative build target.
71
+ A configuration file is provided that includes styles setup and modern React JSX transform.
72
+
73
+ **Note:** This config uses `"jsx": "react-jsx"` (the new JSX transform from React 17+), which means you don't need to import React in every file that uses JSX.
51
74
 
52
75
  ```json
53
76
  {
@@ -59,11 +82,18 @@ A configuration file is provided that included styles setup and a more conservat
59
82
  }
60
83
  ```
61
84
 
85
+ The React DOM config includes type definitions for:
86
+
87
+ - Image imports (`.svg`, `.png`, `.jpg`, etc.)
88
+ - Style imports (`.css`, `.scss`, `.module.css`, etc.)
89
+
62
90
  ### NestJS Project
63
91
 
64
92
  To start, create a `tsconfig.json` in the root of your project.
65
93
 
66
- A typical setup where the application sit in `[project root]/app` folder is as follow:
94
+ **Note:** The NestJS config uses CommonJS module system (`"module": "commonjs"`) and Node.js module resolution, which is optimal for NestJS applications.
95
+
96
+ A typical setup where the application sit in `[project root]/src` folder is as follow:
67
97
 
68
98
  ```json
69
99
  {
@@ -77,15 +107,16 @@ A typical setup where the application sit in `[project root]/app` folder is as f
77
107
 
78
108
  ### NodeJS Project
79
109
 
80
- #### Node Application Project
110
+ **Note:** The Node.js config uses modern ESM module resolution (`"moduleResolution": "NodeNext"`). This is optimal for Node.js 18+ with native ESM support. If you're using CommonJS, consider using the NestJS config instead.
81
111
 
82
- To start, create a `tsconfig.json` in the root of your project.
83
112
 
84
- A typical setup where the application sit in `[project root]/src` folder is as follow:
113
+ #### Node.js Project (ESM)
114
+
115
+ To start, create a `tsconfig.json` in the root of your project:
85
116
 
86
117
  ```json
87
118
  {
88
- "extends": "@petbee/tsconfig/node/base.json",
119
+ "extends": "@petbee/tsconfig/node.json",
89
120
  "compilerOptions": {
90
121
  "baseUrl": "./",
91
122
  "outDir": "./dist"
@@ -93,24 +124,33 @@ A typical setup where the application sit in `[project root]/src` folder is as f
93
124
  }
94
125
  ```
95
126
 
96
- #### Node Library Project
127
+ **For ESM projects**, ensure your `package.json` has:
97
128
 
98
- Similarly for a node library project. Create a `tsconfig.json` in the root of your project with a setup below assuming the library code sit in `[project root]/src` folder.
129
+ ```json
130
+ {
131
+ "type": "module"
132
+ }
133
+ ```
134
+
135
+
136
+ #### Node.js Project (CommonJS)
137
+
138
+ For legacy Node.js projects using CommonJS, extend the CommonJS config:
99
139
 
100
140
  ```json
101
141
  {
102
- "extends": "@petbee/tsconfig/node/library.json",
142
+ "extends": "@petbee/tsconfig/node/commonjs.json",
103
143
  "compilerOptions": {
104
- "baseUrl": "./src",
105
- "rootDir": "."
106
- },
107
- "include": ["./src/**/*"]
144
+ "baseUrl": "./",
145
+ "outDir": "./dist"
146
+ }
108
147
  }
109
148
  ```
110
149
 
111
- ### All Other Project
112
150
 
113
- A base configuration file is also provided if the above does not fit your need.
151
+ ### Custom/Advanced Usage
152
+
153
+ If you need more control, you can extend any of the granular configs in the framework folders (e.g., `react/library.json`, `node/library.json`, etc.) or the base config directly:
114
154
 
115
155
  ```json
116
156
  {
@@ -122,6 +162,23 @@ A base configuration file is also provided if the above does not fit your need.
122
162
  }
123
163
  ```
124
164
 
165
+ ### TypeScript Configuration Notes
166
+
167
+ #### Plugins
168
+
169
+ - If you override the `plugins` array in your project’s tsconfig.json, **always include** the Next.js plugin for Next.js projects:
170
+ ```json
171
+ "plugins": [
172
+ { "name": "next" }
173
+ ]
174
+ ```
175
+ - Omitting the Next.js plugin may cause type-checking and IDE features to break.
176
+
177
+ #### Include/Exclude
178
+
179
+ - If you set your own `include` or `exclude` arrays, they will completely replace those from the base config.
180
+ - Use the recommended patterns from the base config unless you have a specific need.
181
+
125
182
  ## Common Got Ya
126
183
 
127
184
  #### Type Checking does not honour `skipLibCheck: true` setting
package/base.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "compileOnSave": false,
3
3
  "compilerOptions": {
4
+ "target": "ES2022",
5
+ "lib": ["ES2023", "DOM"],
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler",
4
8
  "esModuleInterop": true,
5
9
  "isolatedModules": true,
10
+ "verbatimModuleSyntax": true,
6
11
  "experimentalDecorators": true,
7
- "lib": ["dom", "es2020"],
8
- "moduleResolution": "node",
9
12
  "noImplicitAny": true,
10
13
  "noImplicitReturns": true,
11
14
  "noImplicitThis": true,
12
15
  "noUnusedLocals": true,
13
16
  "noUnusedParameters": true,
17
+ "noUncheckedIndexedAccess": true,
18
+ "allowUnusedLabels": false,
19
+ "allowUnreachableCode": false,
14
20
  "resolveJsonModule": true,
15
21
  "skipLibCheck": true,
16
22
  "strict": true,
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "moduleResolution": "node",
6
+ "declaration": true,
7
+ "removeComments": true,
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "sourceMap": true,
12
+ "outDir": "./dist",
13
+ "baseUrl": "./",
14
+ "incremental": true,
15
+ "strictPropertyInitialization": false
16
+ },
17
+ "exclude": ["node_modules", "dist"]
18
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "dangerfile.ts", "prisma"],
4
+ "compilerOptions": {
5
+ "strictNullChecks": true,
6
+ "incremental": false,
7
+ "composite": false
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "@generated", "prisma"],
4
+ "compilerOptions": {
5
+ "strictNullChecks": true
6
+ }
7
+ }
package/nestjs.json CHANGED
@@ -1,17 +1,3 @@
1
1
  {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "removeComments": true,
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "allowSyntheticDefaultImports": true,
9
- "target": "es2020",
10
- "sourceMap": true,
11
- "outDir": "./dist",
12
- "baseUrl": "./",
13
- "incremental": true,
14
- "skipLibCheck": true,
15
- "esModuleInterop": true
16
- }
2
+ "extends": "./nestjs/base.json"
17
3
  }
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../base.json",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "plugins": [
7
+ {
8
+ "name": "next"
9
+ }
10
+ ],
11
+ "jsx": "preserve",
12
+ "allowJs": true,
13
+ "noEmit": true,
14
+ "incremental": true,
15
+ "removeComments": false,
16
+ "importHelpers": true,
17
+ "downlevelIteration": true,
18
+ "skipDefaultLibCheck": true,
19
+ "useDefineForClassFields": true,
20
+ "verbatimModuleSyntax": false,
21
+ "experimentalDecorators": false,
22
+ "emitDecoratorMetadata": false
23
+ }
24
+ }
package/nextjs.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./nextjs/base.json"
3
+ }
package/node/base.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
- "compileOnSave": false,
2
+ "extends": "../../base.json",
3
3
  "compilerOptions": {
4
- "esModuleInterop": true,
5
- "isolatedModules": true,
6
- "experimentalDecorators": true,
7
- "lib": ["es2020"],
8
- "moduleResolution": "node",
9
- "noUnusedLocals": true,
10
- "noUnusedParameters": true,
11
- "resolveJsonModule": true,
12
- "skipLibCheck": true,
13
- "strict": true
4
+ "target": "ES2022",
5
+ "lib": ["ES2023"],
6
+ "module": "NodeNext",
7
+ "moduleResolution": "NodeNext"
14
8
  }
15
9
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": {
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node"
6
+ }
7
+ }
package/node.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./node/base.json"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/tsconfig",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,5 +15,5 @@
15
15
  "peerDependencies": {
16
16
  "typescript": "^3 || ^4 || ^5"
17
17
  },
18
- "gitHead": "0885e6ebef089afcee9b87428cf90ecb8c95e946"
18
+ "gitHead": "691cd678231d15a665a7bb1751cac4c2fa3789b1"
19
19
  }
@@ -0,0 +1,39 @@
1
+ declare module '*.svg' {
2
+ const content: string
3
+ export default content
4
+ }
5
+
6
+ declare module '*.png' {
7
+ const content: string
8
+ export default content
9
+ }
10
+
11
+ declare module '*.jpg' {
12
+ const content: string
13
+ export default content
14
+ }
15
+
16
+ declare module '*.jpeg' {
17
+ const content: string
18
+ export default content
19
+ }
20
+
21
+ declare module '*.gif' {
22
+ const content: string
23
+ export default content
24
+ }
25
+
26
+ declare module '*.webp' {
27
+ const content: string
28
+ export default content
29
+ }
30
+
31
+ declare module '*.ico' {
32
+ const content: string
33
+ export default content
34
+ }
35
+
36
+ declare module '*.bmp' {
37
+ const content: string
38
+ export default content
39
+ }
@@ -0,0 +1,39 @@
1
+ declare module '*.css' {
2
+ const content: { [className: string]: string }
3
+ export default content
4
+ }
5
+
6
+ declare module '*.scss' {
7
+ const content: { [className: string]: string }
8
+ export default content
9
+ }
10
+
11
+ declare module '*.sass' {
12
+ const content: { [className: string]: string }
13
+ export default content
14
+ }
15
+
16
+ declare module '*.less' {
17
+ const content: { [className: string]: string }
18
+ export default content
19
+ }
20
+
21
+ declare module '*.module.css' {
22
+ const content: { [className: string]: string }
23
+ export default content
24
+ }
25
+
26
+ declare module '*.module.scss' {
27
+ const content: { [className: string]: string }
28
+ export default content
29
+ }
30
+
31
+ declare module '*.module.sass' {
32
+ const content: { [className: string]: string }
33
+ export default content
34
+ }
35
+
36
+ declare module '*.module.less' {
37
+ const content: { [className: string]: string }
38
+ export default content
39
+ }
package/react/dom.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
- "extends": "../base.json",
2
+ "extends": "../../base.json",
3
3
  "compilerOptions": {
4
- "jsx": "react",
5
- "lib": ["dom", "dom.iterable", "scripthost", "es2020"],
6
- "module": "esnext",
7
- "target": "es2020"
4
+ "jsx": "react-jsx",
5
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "target": "ES2022"
8
8
  },
9
9
  "files": ["./definitions/images.d.ts", "./definitions/styles.d.ts"]
10
10
  }
package/react.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./react/dom.json"
3
+ }