@petbee/tsconfig 2.0.0 → 3.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/README.md +46 -4
- package/base.json +8 -2
- package/nestjs.json +6 -2
- package/node/base.json +10 -3
- package/package.json +2 -2
- package/react/definitions/images.d.ts +39 -0
- package/react/definitions/styles.d.ts +39 -0
- package/react/dom.json +4 -4
package/README.md
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
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
|
+
This package provides different configs optimized for different project types:
|
|
23
|
+
|
|
24
|
+
- **`base.json`** - For bundled web apps (Vite, Webpack) - Uses `"moduleResolution": "bundler"`
|
|
25
|
+
- **`node/base.json`** - For Node.js ESM projects - Uses `"moduleResolution": "NodeNext"`
|
|
26
|
+
- **`nestjs.json`** - For NestJS projects - Uses `"moduleResolution": "node"` (CommonJS)
|
|
27
|
+
- **`react/*`** - For React projects - Uses modern JSX transform
|
|
28
|
+
|
|
11
29
|
## Usage
|
|
12
30
|
|
|
13
31
|
### React Project
|
|
@@ -47,7 +65,9 @@ Similarly for a react library project. Create a `tsconfig.json` in the root of y
|
|
|
47
65
|
|
|
48
66
|
#### Project that run in the browser
|
|
49
67
|
|
|
50
|
-
A configuration file is provided that
|
|
68
|
+
A configuration file is provided that includes styles setup and modern React JSX transform.
|
|
69
|
+
|
|
70
|
+
**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
71
|
|
|
52
72
|
```json
|
|
53
73
|
{
|
|
@@ -59,11 +79,18 @@ A configuration file is provided that included styles setup and a more conservat
|
|
|
59
79
|
}
|
|
60
80
|
```
|
|
61
81
|
|
|
82
|
+
The React DOM config includes type definitions for:
|
|
83
|
+
|
|
84
|
+
- Image imports (`.svg`, `.png`, `.jpg`, etc.)
|
|
85
|
+
- Style imports (`.css`, `.scss`, `.module.css`, etc.)
|
|
86
|
+
|
|
62
87
|
### NestJS Project
|
|
63
88
|
|
|
64
89
|
To start, create a `tsconfig.json` in the root of your project.
|
|
65
90
|
|
|
66
|
-
|
|
91
|
+
**Note:** The NestJS config uses CommonJS module system (`"module": "commonjs"`) and Node.js module resolution, which is optimal for NestJS applications.
|
|
92
|
+
|
|
93
|
+
A typical setup where the application sit in `[project root]/src` folder is as follow:
|
|
67
94
|
|
|
68
95
|
```json
|
|
69
96
|
{
|
|
@@ -77,6 +104,8 @@ A typical setup where the application sit in `[project root]/app` folder is as f
|
|
|
77
104
|
|
|
78
105
|
### NodeJS Project
|
|
79
106
|
|
|
107
|
+
**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
|
+
|
|
80
109
|
#### Node Application Project
|
|
81
110
|
|
|
82
111
|
To start, create a `tsconfig.json` in the root of your project.
|
|
@@ -93,6 +122,14 @@ A typical setup where the application sit in `[project root]/src` folder is as f
|
|
|
93
122
|
}
|
|
94
123
|
```
|
|
95
124
|
|
|
125
|
+
**For ESM projects**, ensure your `package.json` has:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"type": "module"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
96
133
|
#### Node Library Project
|
|
97
134
|
|
|
98
135
|
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.
|
|
@@ -112,6 +149,11 @@ Similarly for a node library project. Create a `tsconfig.json` in the root of yo
|
|
|
112
149
|
|
|
113
150
|
A base configuration file is also provided if the above does not fit your need.
|
|
114
151
|
|
|
152
|
+
**Note:** The base config uses `"moduleResolution": "bundler"`, which is optimal for projects using modern bundlers (Vite, Webpack 5+, esbuild, etc.). If you need different module resolution:
|
|
153
|
+
|
|
154
|
+
- For Node.js ESM: use `node/base.json`
|
|
155
|
+
- For CommonJS: use `nestjs.json` or override with `"moduleResolution": "node"`
|
|
156
|
+
|
|
115
157
|
```json
|
|
116
158
|
{
|
|
117
159
|
"extends": "@petbee/tsconfig/base.json",
|
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,
|
package/nestjs.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023"],
|
|
3
5
|
"module": "commonjs",
|
|
6
|
+
"moduleResolution": "node",
|
|
4
7
|
"declaration": true,
|
|
5
8
|
"removeComments": true,
|
|
6
9
|
"emitDecoratorMetadata": true,
|
|
7
10
|
"experimentalDecorators": true,
|
|
8
11
|
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"target": "es2020",
|
|
10
12
|
"sourceMap": true,
|
|
11
13
|
"outDir": "./dist",
|
|
12
14
|
"baseUrl": "./",
|
|
13
15
|
"incremental": true,
|
|
14
16
|
"skipLibCheck": true,
|
|
15
|
-
"esModuleInterop": true
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"strict": true
|
|
16
20
|
}
|
|
17
21
|
}
|
package/node/base.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compileOnSave": false,
|
|
3
3
|
"compilerOptions": {
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "NodeNext",
|
|
7
|
+
"moduleResolution": "NodeNext",
|
|
4
8
|
"esModuleInterop": true,
|
|
5
9
|
"isolatedModules": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
6
11
|
"experimentalDecorators": true,
|
|
7
|
-
"lib": ["es2020"],
|
|
8
|
-
"moduleResolution": "node",
|
|
9
12
|
"noUnusedLocals": true,
|
|
10
13
|
"noUnusedParameters": true,
|
|
14
|
+
"noUncheckedIndexedAccess": true,
|
|
15
|
+
"allowUnusedLabels": false,
|
|
16
|
+
"allowUnreachableCode": false,
|
|
11
17
|
"resolveJsonModule": true,
|
|
12
18
|
"skipLibCheck": true,
|
|
13
|
-
"strict": true
|
|
19
|
+
"strict": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true
|
|
14
21
|
}
|
|
15
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/tsconfig",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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": "e78d31f90c9546fa3b7e1959902bc6d703956349"
|
|
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
2
|
"extends": "../base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"jsx": "react",
|
|
5
|
-
"lib": ["
|
|
6
|
-
"module": "
|
|
7
|
-
"target": "
|
|
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
|
}
|