Skip to content

Commit

Permalink
feat: upgrade to TypeScript 5 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhofer authored Mar 23, 2023
1 parent 8b5b844 commit e97b58d
Show file tree
Hide file tree
Showing 10 changed files with 915 additions and 619 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-elephants-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"exceptionally": major
---

upgrade to TypeScript 5
5 changes: 5 additions & 0 deletions .changeset/tricky-chefs-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"exceptionally": major
---

improve type definition for `processInParallel`
6 changes: 3 additions & 3 deletions .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"semiColons": "asi"
},
"plugins": [
"https://plugins.dprint.dev/typescript-0.74.0.wasm",
"https://plugins.dprint.dev/json-0.15.6.wasm",
"https://plugins.dprint.dev/markdown-0.14.1.wasm",
"https://plugins.dprint.dev/typescript-0.84.0.wasm",
"https://plugins.dprint.dev/json-0.17.1.wasm",
"https://plugins.dprint.dev/markdown-0.15.2.wasm",
"https://plugins.dprint.dev/dockerfile-0.3.0.wasm"
],
"includes": [
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"**/lib": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"markdown.extension.toc.updateOnSave": false
"markdown.extension.toc.updateOnSave": false,
"editor.defaultFormatter": "dprint.dprint"
}
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,18 @@ This packages delivers a solution to all the problems described above.

## Installation

### TypeScript version 5.0 or higher

```bash
npm install exceptionally
```

### TypeScript version 4.x

```bash
npm install exceptionally@2
```

> You should also set everything to [`strict` mode](https://www.typescriptlang.org/tsconfig#strict) in your `tsconfig.json` to get the most out of this package.
## Basics
Expand Down Expand Up @@ -533,18 +541,18 @@ There exist similar approaches how to best handle errors and exceptions in appli
| | `exceptionally` | `[data,error] tuple` | `{data,error} object` | `neverthrow` | `@badrap/result` |
| ----------------------------------------------------------------------------------- | --------------- | -------------------- | --------------------- | ------------ | ---------------- |
| prevents try-catch blocks (example 1) | ✅ | ✅ | ✅ | ✅ | ✅ |
| typesafe error handling (example 1) | ✅ | ✅ | ✅ | ✅ | ✅ |
| obvious how to handle falsy return values (example 2) | ✅ | ❌ | ❌ | ✅ | ✅ |
| can access error object without needing to store it as a variable first (example 3) | ✅ | ❌ | ❌ | ✅ | ✅ |
| does not require you to come up with new two variable names per result (example 4) | ✅ | ❌ | ❌ | ✅ | ✅ |
| obvious how to handle no data and no error return values (example 5) | ✅ | ❌ | ❌ | ✅ | ✅ |
| Error can be any data | ✅ | ✅ | ✅ | ✅ | ❌ |
| can detect uncaught errors without an additional package | ✅ | ❌ | ❌ | ❌ | ✅ |
| will never throw (unless you really want it) | ✅ | ✅ | ✅ | ❌ | ❌ |
| offer useful functions to work with the library more easily | ✅ | ❌ | ❌ | ✅ | ✅ |
| adds less than `0.5kb` to your bundle | ✅ | ➖ | ➖ | ❌ | ❌ |
| has chosen an "exceptionally" name 😋 | ✅ | ❌ | ❌ | ❌ | ❌ |
| prevents try-catch blocks (example 1) | ✅ | ✅ | ✅ | ✅ | ✅ |
| typesafe error handling (example 1) | ✅ | ✅ | ✅ | ✅ | ✅ |
| obvious how to handle falsy return values (example 2) | ✅ | ❌ | ❌ | ✅ | ✅ |
| can access error object without needing to store it as a variable first (example 3) | ✅ | ❌ | ❌ | ✅ | ✅ |
| does not require you to come up with new two variable names per result (example 4) | ✅ | ❌ | ❌ | ✅ | ✅ |
| obvious how to handle no data and no error return values (example 5) | ✅ | ❌ | ❌ | ✅ | ✅ |
| Error can be any data | ✅ | ✅ | ✅ | ✅ | ❌ |
| can detect uncaught errors without an additional package | ✅ | ❌ | ❌ | ❌ | ✅ |
| will never throw (unless you really want it) | ✅ | ✅ | ✅ | ❌ | ❌ |
| offer useful functions to work with the library more easily | ✅ | ❌ | ❌ | ✅ | ✅ |
| adds less than `0.5kb` to your bundle | ✅ | ➖ | ➖ | ❌ | ❌ |
| has chosen an "exceptionally" name 😋 | ✅ | ❌ | ❌ | ❌ | ❌ |
> Do you have other examples? Please open a PR and add them to the table.
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@
"lint-staged": "lint-staged"
},
"devDependencies": {
"@changesets/cli": "^2.25.0",
"@size-limit/preset-small-lib": "^8.1.0",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"dprint": "^0.32.1",
"eslint": "^8.25.0",
"eslint-config-xo": "^0.42.0",
"eslint-config-xo-typescript": "^0.53.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"size-limit": "^8.1.0",
"tsup": "^6.2.3",
"typescript": "^4.8.4",
"undici": "^5.11.0",
"vite": "^3.1.8",
"vitest": "^0.24.1"
"@changesets/cli": "^2.26.1",
"@size-limit/preset-small-lib": "^8.2.4",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"dprint": "^0.35.3",
"eslint": "^8.36.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^0.56.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"size-limit": "^8.2.4",
"tsup": "^6.7.0",
"typescript": "^5.0.2",
"undici": "^5.21.0",
"vite": "^4.2.1",
"vitest": "^0.29.7"
},
"peerDependencies": {
"typescript": "^4.0"
"typescript": "^5.0"
},
"type": "module",
"main": "./lib/legacy.cjs",
Expand Down
Loading

0 comments on commit e97b58d

Please sign in to comment.