Skip to content

Commit

Permalink
feat: Eliminate typings folder in favor of per-target types
Browse files Browse the repository at this point in the history
Took some doing since there's no nice way in TS of omitting comments from the resulting JS files but keeping them in the TS files. See microsoft/TypeScript#14619 for the relevant issue discussing this.

Fixes MichalLytek#1442
  • Loading branch information
kf6kjg committed Apr 7, 2023
1 parent e15b4d0 commit ac3e79b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@
"exports": {
".": {
"require": "./build/cjs/index.js",
"import": "./build/esm/index.js",
"types": "./build/typings/index.d.ts"
"import": "./build/esm/index.js"
}
},
"main": "./build/cjs/index.js",
"module": "./build/esm/index.js",
"types": "./build/typings/index.d.ts",
"files": [
"./build"
],
"scripts": {
"prebuild": "npm run clean && npm run check:version",
"build": "npx tsc --build ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.typings.json",
"postbuild": "npx shx rm ./build/typings/browser-shim.d.ts && npx shx cp ./src/browser-shim.ts ./build/typings && npx ts-node ./scripts/package.json.ts",
"build": "npx tsc --build ./tsconfig.cjs.json ./tsconfig.cjs.d.json ./tsconfig.esm.json ./tsconfig.esm.d.json",
"postbuild": "npx ts-node ./scripts/package.json.ts",
"prebuild:benchmarks": "npm run clean",
"build:benchmarks": "npx tsc --project ./benchmarks/tsconfig.json",
"build:examples": "npm run --prefix ./examples build",
Expand All @@ -65,9 +63,7 @@
"check:type": "npx npm-run-all --npm-path npm \"check:type:*\"",
"check:type:cjs": "npx tsc --project ./tsconfig.cjs.json --noEmit",
"check:type:esm": "npx tsc --project ./tsconfig.esm.json --noEmit",
"check:type:typings": "npx tsc --project ./tsconfig.typings.json --noEmit --emitDeclarationOnly false",
"check:type:benchmarks": "npx tsc --project ./benchmarks/tsconfig.json --noEmit",
"precheck:type:examples": "npx tsc --project ./tsconfig.typings.json",
"check:type:examples": "npx tsc --project ./examples/tsconfig.json --noEmit",
"check:type:scripts": "npx tsc --project ./scripts/tsconfig.json --noEmit",
"check:version": "npx ts-node ./scripts/version.ts",
Expand Down
15 changes: 15 additions & 0 deletions tsconfig.cjs.d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.cjs.json",
"compilerOptions": {
// See https://github.com/webstrand/typescript-remove-comments-not-from-declarations for the source of inspiration.

"declaration": true,
"emitDeclarationOnly": true,
"removeComments": false,

// performance enhancement
"disableSolutionSearching": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true
}
}
15 changes: 15 additions & 0 deletions tsconfig.esm.d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.esm.json",
"compilerOptions": {
// See https://github.com/webstrand/typescript-remove-comments-not-from-declarations for the source of inspiration.

"declaration": true,
"emitDeclarationOnly": true,
"removeComments": false,

// performance enhancement
"disableSolutionSearching": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"moduleResolution": "node16",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down
9 changes: 0 additions & 9 deletions tsconfig.typings.json

This file was deleted.

0 comments on commit ac3e79b

Please sign in to comment.