@petbee/tsconfig 3.0.0 → 3.0.2
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 +44 -29
- package/nestjs/base.json +18 -0
- package/nestjs/build.json +9 -0
- package/nestjs/eslint.json +7 -0
- package/nestjs.json +1 -19
- package/nextjs/base.json +24 -0
- package/nextjs.json +3 -0
- package/node/base.json +2 -15
- package/node/commonjs.json +7 -0
- package/node.json +3 -0
- package/package.json +2 -2
- package/react.json +3 -0
package/README.md
CHANGED
|
@@ -19,32 +19,35 @@ yarn add -D @petbee/tsconfig typescript
|
|
|
19
19
|
|
|
20
20
|
## Module Resolution Guide
|
|
21
21
|
|
|
22
|
-
This package provides different configs optimized for different project types:
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- **`
|
|
27
|
-
- **`react
|
|
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`).
|
|
28
33
|
|
|
29
34
|
## Usage
|
|
30
35
|
|
|
31
36
|
### React Project
|
|
32
37
|
|
|
33
|
-
#### React Application Project
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
#### React Project
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
To start, create a `tsconfig.json` in the root of your project:
|
|
38
42
|
|
|
39
43
|
```json
|
|
40
44
|
{
|
|
41
|
-
"extends": "@petbee/tsconfig/react
|
|
45
|
+
"extends": "@petbee/tsconfig/react.json",
|
|
42
46
|
"compilerOptions": {
|
|
43
47
|
"baseUrl": ".",
|
|
44
|
-
"rootDir": "."
|
|
45
|
-
"paths": { "*": ["*", "app/*"] }
|
|
48
|
+
"rootDir": "."
|
|
46
49
|
},
|
|
47
|
-
"include": ["./
|
|
50
|
+
"include": ["./src/**/*"]
|
|
48
51
|
}
|
|
49
52
|
```
|
|
50
53
|
|
|
@@ -106,15 +109,14 @@ A typical setup where the application sit in `[project root]/src` folder is as f
|
|
|
106
109
|
|
|
107
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.
|
|
108
111
|
|
|
109
|
-
#### Node Application Project
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
#### Node.js Project (ESM)
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
To start, create a `tsconfig.json` in the root of your project:
|
|
114
116
|
|
|
115
117
|
```json
|
|
116
118
|
{
|
|
117
|
-
"extends": "@petbee/tsconfig/node
|
|
119
|
+
"extends": "@petbee/tsconfig/node.json",
|
|
118
120
|
"compilerOptions": {
|
|
119
121
|
"baseUrl": "./",
|
|
120
122
|
"outDir": "./dist"
|
|
@@ -130,29 +132,25 @@ A typical setup where the application sit in `[project root]/src` folder is as f
|
|
|
130
132
|
}
|
|
131
133
|
```
|
|
132
134
|
|
|
133
|
-
#### Node Library Project
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
#### Node.js Project (CommonJS)
|
|
137
|
+
|
|
138
|
+
For legacy Node.js projects using CommonJS, extend the CommonJS config:
|
|
136
139
|
|
|
137
140
|
```json
|
|
138
141
|
{
|
|
139
|
-
"extends": "@petbee/tsconfig/node/
|
|
142
|
+
"extends": "@petbee/tsconfig/node/commonjs.json",
|
|
140
143
|
"compilerOptions": {
|
|
141
|
-
"baseUrl": "./
|
|
142
|
-
"
|
|
143
|
-
}
|
|
144
|
-
"include": ["./src/**/*"]
|
|
144
|
+
"baseUrl": "./",
|
|
145
|
+
"outDir": "./dist"
|
|
146
|
+
}
|
|
145
147
|
}
|
|
146
148
|
```
|
|
147
149
|
|
|
148
|
-
### All Other Project
|
|
149
|
-
|
|
150
|
-
A base configuration file is also provided if the above does not fit your need.
|
|
151
150
|
|
|
152
|
-
|
|
151
|
+
### Custom/Advanced Usage
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
- For CommonJS: use `nestjs.json` or override with `"moduleResolution": "node"`
|
|
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:
|
|
156
154
|
|
|
157
155
|
```json
|
|
158
156
|
{
|
|
@@ -164,6 +162,23 @@ A base configuration file is also provided if the above does not fit your need.
|
|
|
164
162
|
}
|
|
165
163
|
```
|
|
166
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
|
+
|
|
167
182
|
## Common Got Ya
|
|
168
183
|
|
|
169
184
|
#### Type Checking does not honour `skipLibCheck: true` setting
|
package/nestjs/base.json
ADDED
|
@@ -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
|
+
}
|
package/nestjs.json
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"lib": ["ES2023"],
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"removeComments": true,
|
|
9
|
-
"emitDecoratorMetadata": true,
|
|
10
|
-
"experimentalDecorators": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"outDir": "./dist",
|
|
14
|
-
"baseUrl": "./",
|
|
15
|
-
"incremental": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"esModuleInterop": true,
|
|
18
|
-
"forceConsistentCasingInFileNames": true,
|
|
19
|
-
"strict": true
|
|
20
|
-
}
|
|
2
|
+
"extends": "./nestjs/base.json"
|
|
21
3
|
}
|
package/nextjs/base.json
ADDED
|
@@ -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
package/node/base.json
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"extends": "../base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "ES2022",
|
|
5
5
|
"lib": ["ES2023"],
|
|
6
6
|
"module": "NodeNext",
|
|
7
|
-
"moduleResolution": "NodeNext"
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"isolatedModules": true,
|
|
10
|
-
"verbatimModuleSyntax": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"noUnusedLocals": true,
|
|
13
|
-
"noUnusedParameters": true,
|
|
14
|
-
"noUncheckedIndexedAccess": true,
|
|
15
|
-
"allowUnusedLabels": false,
|
|
16
|
-
"allowUnreachableCode": false,
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"skipLibCheck": true,
|
|
19
|
-
"strict": true,
|
|
20
|
-
"forceConsistentCasingInFileNames": true
|
|
7
|
+
"moduleResolution": "NodeNext"
|
|
21
8
|
}
|
|
22
9
|
}
|
package/node.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/tsconfig",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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": "
|
|
18
|
+
"gitHead": "abe6270b98022de98e790e3c06e568d5334845e1"
|
|
19
19
|
}
|
package/react.json
ADDED