@r0hitsharma/tsconfig 0.12.0-rohit-fork-ci.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 +71 -0
- package/base.json +13 -0
- package/node.json +14 -0
- package/package.json +21 -0
- package/react.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @r0hitsharma/tsconfig
|
|
2
|
+
|
|
3
|
+
Shared TypeScript configuration presets for projects across the organization.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @r0hitsharma/tsconfig typescript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Extend the appropriate preset in your project's `tsconfig.json`:
|
|
14
|
+
|
|
15
|
+
### Base configuration
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"extends": "@r0hitsharma/tsconfig/base",
|
|
20
|
+
"compilerOptions": {
|
|
21
|
+
"outDir": "./dist"
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Node.js projects
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"extends": "@r0hitsharma/tsconfig/node"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### React projects
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"extends": "@r0hitsharma/tsconfig/react"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Included presets
|
|
44
|
+
|
|
45
|
+
- **base** - General-purpose TypeScript configuration
|
|
46
|
+
- **node** - Configuration optimized for Node.js applications
|
|
47
|
+
- **react** - Configuration optimized for React projects with JSX support
|
|
48
|
+
|
|
49
|
+
## `noUncheckedIndexedAccess`
|
|
50
|
+
|
|
51
|
+
`base` enables `noUncheckedIndexedAccess`, so an indexed read (`arr[i]`,
|
|
52
|
+
`record[key]`) is typed `T | undefined`. This catches the case where a lookup
|
|
53
|
+
misses and the `undefined` flows onward instead of throwing — an unguarded
|
|
54
|
+
regex-group read or bucket lookup rendering `undefined` into a value.
|
|
55
|
+
|
|
56
|
+
Upgrading surfaces new errors in existing code. The migration is mechanical;
|
|
57
|
+
in rough order of preference:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const first = items[0] ?? fallback; // a real default
|
|
61
|
+
const row = rows[i];
|
|
62
|
+
if (row === undefined) continue; // a guard that narrows
|
|
63
|
+
|
|
64
|
+
// Where the index is provably in range (a modulo, or a loop bound), make the
|
|
65
|
+
// source a non-empty tuple so element 0 is typed:
|
|
66
|
+
const NAMES = ['a', 'b', 'c'] as const;
|
|
67
|
+
const name = NAMES[i % NAMES.length] ?? NAMES[0];
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To defer it for a workspace, set `"noUncheckedIndexedAccess": false` in that
|
|
71
|
+
project's own `compilerOptions`.
|
package/base.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"strict": true,
|
|
5
|
+
"noUncheckedIndexedAccess": true,
|
|
6
|
+
"noUnusedLocals": true,
|
|
7
|
+
"noUnusedParameters": true,
|
|
8
|
+
"erasableSyntaxOnly": true,
|
|
9
|
+
"noFallthroughCasesInSwitch": true,
|
|
10
|
+
"noUncheckedSideEffectImports": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
}
|
|
13
|
+
}
|
package/node.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2023",
|
|
6
|
+
"lib": ["ES2023"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
11
|
+
"moduleDetection": "force",
|
|
12
|
+
"noEmit": true
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@r0hitsharma/tsconfig",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"base.json",
|
|
9
|
+
"react.json",
|
|
10
|
+
"node.json"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./base": "./base.json",
|
|
14
|
+
"./react": "./react.json",
|
|
15
|
+
"./node": "./node.json"
|
|
16
|
+
},
|
|
17
|
+
"version": "0.12.0-rohit-fork-ci.1",
|
|
18
|
+
"repository": {
|
|
19
|
+
"url": "https://github.com/r0hitsharma/uikit"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/react.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"useDefineForClassFields": true,
|
|
7
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"jsx": "react-jsx"
|
|
15
|
+
}
|
|
16
|
+
}
|