Skip to content

Commit dc48f8a

Browse files
committed
fix: Ensure Promise rejection reasons are Error objects
- Replace unsafe 'as Error' cast with proper type guard - Enable noImplicitReturns and useUnknownInCatchVariables for stricter type checking - Fixes TypeScript ESLint prefer-promise-reject-errors rule compliance
1 parent f3677ff commit dc48f8a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/test/suite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function run(): Promise<void> {
3434
});
3535
} catch (err) {
3636
console.error(err);
37-
e(err as Error);
37+
e(err instanceof Error ? err : new Error(String(err)));
3838
}
3939
});
4040
});

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"lib": ["ES2020"],
66
"sourceMap": true,
77
"rootDir": "src",
8-
"strict": true /* enable all strict type-checking options */
8+
"strict": true /* enable all strict type-checking options */,
99
/* Additional Checks */
10-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
10+
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
11+
"useUnknownInCatchVariables": true /* Type caught variables as 'unknown' instead of 'any' */
1112
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
1213
// "noUnusedParameters": true, /* Report errors on unused parameters. */
1314
}

0 commit comments

Comments
 (0)