Skip to content

Commit 7dd7691

Browse files
Merge pull request #3 from nakanoasaservice/feature/change-default-cause
feat!: Change default 'cause' type to undefined for type safety
2 parents 23b10a5 + 9e1bd31 commit 7dd7691

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.7",
2+
"version": "1.0.0",
33
"name": "@nakanoaas/tagged-error",
44
"license": "MIT",
55
"exports": "./index.ts",

index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("TaggedError in practice", () => {
7575
result.message,
7676
"Cannot calculate square root of negative number",
7777
);
78-
assertEquals(result.cause.value, -10);
78+
assertEquals(result.cause?.value, -10);
7979
});
8080
});
8181

index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Options for creating a TaggedError
33
* @template Cause - The type of the cause data
44
*/
5-
interface TaggedErrorOptions<Cause = never> {
5+
interface TaggedErrorOptions<Cause = undefined> {
66
/** Optional error message */
77
message?: string;
88
/** Optional cause data */
@@ -31,7 +31,7 @@ interface TaggedErrorOptions<Cause = never> {
3131
* }
3232
* ```
3333
*/
34-
export class TaggedError<Tag extends string, Cause = never> extends Error {
34+
export class TaggedError<Tag extends string, Cause = undefined> extends Error {
3535
/** The tag identifying the type of error */
3636
tag: Tag;
3737
/** The cause data associated with the error */

llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Tagged Error is a TypeScript library that provides type-safe error handling with
4040

4141
## Type Parameters
4242
- `Tag extends string`: The literal string type of the error tag
43-
- `Cause = never`: The type of the cause data (optional)
43+
- `Cause = undefined`: The type of the cause data (optional)
4444

4545
## Constructor
4646
```typescript

0 commit comments

Comments
 (0)