@serkonda7/ts-result 1.0.3 → 1.0.5

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 CHANGED
@@ -6,6 +6,11 @@
6
6
  Minimalistic Result type for TypeScript.
7
7
 
8
8
 
9
+ ## ⚠️ Archived
10
+ This project is archived.
11
+ I recommend using [better-result](https://github.com/dmmulroy/better-result) instead.
12
+
13
+
9
14
  ## 📦 Installation
10
15
  ```sh
11
16
  npm install @serkonda7/ts-result
@@ -26,7 +31,7 @@ function parsePort (input: string): Result<number> {
26
31
  }
27
32
 
28
33
  if (port < 1 || port > 65535) {
29
- // It supports strings, Error classes or any custom object
34
+ // It supports strings and Error classes
30
35
  return err(new Error('PORT must be between 1 and 65535'))
31
36
  }
32
37
 
@@ -50,6 +55,33 @@ const port = unwrap(portResult)
50
55
  ```
51
56
 
52
57
 
58
+ ## 🧹 Linter Configuration
59
+ To avoid exception-based control flow, configure your linter to disallow `throw` statements in application code.
60
+
61
+ ### Biome example configuration
62
+ ```gritql
63
+ // no-throw.grit
64
+
65
+ language js (typescript, jsx);
66
+
67
+ `throw $expr` as $throw where {
68
+ register_diagnostic(
69
+ span = $throw,
70
+ message = "Use Result 'return err(...)' instead of `throw`"
71
+ )
72
+ }
73
+ ```
74
+
75
+ ```jsonc
76
+ // biome.jsonc
77
+
78
+ {
79
+ // ...
80
+ "plugins": ["./no-throw.grit"]
81
+ }
82
+ ```
83
+
84
+
53
85
  ## 📜 License
54
86
  This repo is licensed under the [MIT License](LICENSE.txt).
55
87
 
@@ -12,10 +12,11 @@ type Err<E> = {
12
12
  error: E;
13
13
  value?: never;
14
14
  };
15
+ type ErrorTypes = string | Error;
15
16
  /**
16
17
  * Union type representing either success or failure.
17
18
  */
18
- export type Result<V, E = Error> = Ok<V> | Err<E>;
19
+ export type Result<V, E = ErrorTypes> = Ok<V> | Err<E>;
19
20
  /**
20
21
  * Helper to create a successful Result.
21
22
  */
@@ -23,7 +24,7 @@ export declare const ok: <V>(value: V) => Ok<V>;
23
24
  /**
24
25
  * Helper to create a failed Result.
25
26
  */
26
- export declare const err: <E>(error: E) => Err<E>;
27
+ export declare const err: <E extends ErrorTypes>(error: E) => Err<E>;
27
28
  /**
28
29
  * Returns the `value` from a Result.
29
30
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@serkonda7/ts-result",
3
3
  "description": "Minimalistic Result type for TypeScript.",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "license": "MIT",
6
6
  "author": "serkonda7",
7
7
  "homepage": "https://github.com/serkonda7/ts-result",
@@ -20,20 +20,20 @@
20
20
  "scripts": {
21
21
  "lint": "biome check --write",
22
22
  "lint:ci": "biome ci",
23
- "check": "tsgo -p tsconfig.check.json",
23
+ "check": "tsgo",
24
24
  "test": "bun test",
25
- "build": "tsgo && bun run scripts/build.ts",
25
+ "build": "tsgo -p tsconfig.build.json && bun run scripts/build.ts",
26
26
  "prepack": "bun run build",
27
27
  "pack": "bun pm pack --filename ts-result.tgz"
28
28
  },
29
29
  "engines": {
30
30
  "node": ">=22"
31
31
  },
32
- "packageManager": "bun@1.3.11",
32
+ "packageManager": "bun@1.3.13",
33
33
  "dependencies": {},
34
34
  "devDependencies": {
35
- "@biomejs/biome": "2.4.10",
36
- "@types/bun": "~1.3.11",
37
- "@typescript/native-preview": "~7.0.0-dev.20260325.1"
35
+ "@biomejs/biome": "2.4.15",
36
+ "@types/bun": "~1.3.13",
37
+ "@typescript/native-preview": "~7.0.0-dev.20260511.1"
38
38
  }
39
39
  }