Skip to content

Commit fb2fd7a

Browse files
committedApr 17, 2024··
feat: add tsconfig presets
1 parent dbb2faa commit fb2fd7a

9 files changed

+57
-53
lines changed
 

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"require": "./dist/index.cjs",
3131
"default": "./dist/index.js"
3232
},
33+
"./tsconfig/recommended.json": "./tsconfig/recommended.json",
34+
"./tsconfig/strict.json": "./tsconfig/strict.json",
35+
"./tsconfig/strictest.json": "./tsconfig/strictest.json",
3336
"./package.json": "./package.json"
3437
},
3538
"main": "./dist/index.cjs",

‎playground/multi-exports-commonjs/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88
".": {
99
"source": "./src/index.ts",
1010
"import": "./dist/index.mjs",
11-
"require": "./dist/index.js",
1211
"default": "./dist/index.js"
1312
},
1413
"./cli": {
1514
"source": "./src/cli.ts",
16-
"require": "./dist/cli.js",
1715
"default": "./dist/cli.js"
1816
},
1917
"./plugin": {
2018
"source": "./src/plugin.ts",
2119
"import": "./dist/plugin.mjs",
22-
"require": "./dist/plugin.js",
2320
"default": "./dist/plugin.js"
2421
},
2522
"./package.json": "./package.json"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": "@sanity/pkg-utils/tsconfig/recommended.json",
23
"include": ["./src"],
34
"compilerOptions": {
45
"paths": {
@@ -8,11 +9,6 @@
89
"rootDir": ".",
910
"outDir": "./dist",
1011

11-
"target": "ES2020",
12-
"declaration": true,
13-
"declarationMap": true,
14-
"sourceMap": true,
15-
1612
// Strict type-checking
1713
"strict": true,
1814
"noImplicitAny": true,
@@ -27,11 +23,6 @@
2723
"noUnusedParameters": true,
2824
"noImplicitReturns": true,
2925
"noFallthroughCasesInSwitch": true,
30-
"skipLibCheck": true,
31-
32-
// Module resolution
33-
"module": "Preserve",
34-
"moduleDetection": "force",
35-
"allowSyntheticDefaultImports": true
26+
"skipLibCheck": true
3627
}
3728
}

‎playground/ts/tsconfig.settings.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
{
2+
"extends": "@sanity/pkg-utils/tsconfig/recommended.json",
23
"compilerOptions": {
34
"rootDir": ".",
45
"outDir": "dist",
5-
"noEmit": true,
6-
7-
"target": "ESNext",
8-
"module": "Preserve",
9-
"moduleDetection": "force",
106

117
// Strict type-checking
128
"strict": true,

‎tsconfig.json

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
"include": ["./*.cjs", "./*.ts", "./bin", "./package.json", "./scripts", "./src", "./test"],
44
"exclude": ["./test/env/__tmp__"],
55
"compilerOptions": {
6-
"allowJs": true,
7-
86
"baseUrl": "./src",
97
"paths": {
108
"@sanity/pkg-utils": ["./node"]

‎tsconfig.settings.json

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
{
2+
"extends": "@sanity/pkg-utils/tsconfig/strictest.json",
23
"compilerOptions": {
34
"rootDir": ".",
4-
"outDir": "./dist",
5-
"noEmit": true,
6-
7-
// Completeness
8-
"skipLibCheck": true,
9-
10-
// Language and environment
11-
"target": "ES2020",
12-
13-
// Modules
14-
"module": "Preserve",
15-
// These options are set when "module" is "Preserve"
16-
// "moduleResolution": "Bundler",
17-
// "esModuleInterop": true,
18-
// "resolveJsonModule": true,
19-
"moduleDetection": "force",
20-
"isolatedModules": true,
21-
"forceConsistentCasingInFileNames": true,
22-
23-
// Type checking
24-
"allowSyntheticDefaultImports": true,
25-
"alwaysStrict": true,
26-
"noFallthroughCasesInSwitch": true,
27-
"noImplicitAny": true,
28-
"noImplicitReturns": true,
29-
"noImplicitThis": true,
30-
"noUnusedLocals": true,
31-
"noUnusedParameters": true,
32-
"strict": true,
33-
"strictFunctionTypes": true,
34-
"strictNullChecks": true,
35-
"strictPropertyInitialization": true
5+
"outDir": "./dist"
366
}
377
}

‎tsconfig/recommended.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"description": "Sets the right defaults for usage with @sanity/pkg-utils and that JSX is compiled with esbuild, and ESM and CJS with rollup.",
4+
"compilerOptions": {
5+
"lib": ["ESNext"],
6+
"target": "ESNext",
7+
"module": "Preserve",
8+
"moduleResolution": "Bundler",
9+
"esModuleInterop": true,
10+
"resolveJsonModule": true,
11+
"moduleDetection": "force",
12+
"jsx": "preserve",
13+
"allowJs": true,
14+
"noEmit": true,
15+
"allowImportingTsExtensions": true,
16+
"skipLibCheck": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"allowSyntheticDefaultImports": true
19+
}
20+
}

‎tsconfig/strict.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"description": "Extends the recommended preset with stricter settings.",
4+
"extends": "./recommended.json",
5+
"compilerOptions": {
6+
"checkJs": true,
7+
"strict": true,
8+
"noFallthroughCasesInSwitch": true,
9+
"noUnusedLocals": true,
10+
"noUnusedParameters": true,
11+
"noPropertyAccessFromIndexSignature": true,
12+
"isolatedModules": true,
13+
"verbatimModuleSyntax": true
14+
}
15+
}

‎tsconfig/strictest.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"description": "Stricter than strict",
4+
"extends": "./strict.json",
5+
"compilerOptions": {
6+
"alwaysStrict": true,
7+
"noImplicitAny": true,
8+
"noImplicitReturns": true,
9+
"noImplicitThis": true,
10+
"strictFunctionTypes": true,
11+
"strictNullChecks": true,
12+
"strictPropertyInitialization": true
13+
}
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.