Fix tsc errors related to error type checking
CLA
- [x] I have signed the Stream CLA (required).
- [x] Code changes are tested
Description of the changes, What, Why and How?
All catch closures inside connection.ts assumed thrown error is instance of Error while default type of error is unknown. This PR adds proper type checks so compiler won't throw build errors. It should fix this issue.
Changelog
- Fix build errors related to error type checks
@pzmudzinski thanks for your contribution, we will take some time to review and test your PR and get back to you.
@pzmudzinski please have a look and fix linting issues ;)
@vanGalilea I cannot reproduce this error on my local machine. This is output of github action:
Error: src/errors.ts(37,68): error TS2339: Property 'code' does not exist on type 'never'.
This is related code:
export function isAPIError(error: unknown): error is APIError {
return error instanceof Error && 'code' in error && typeof error.code === 'number';
}
I does not really make sense - error is type of unknown, not never. Are we sure everything is setup correctly on build step?
Closing the PR as the root cause of the issue (#1062) was incorrect import that lead to tsc compiling node_modules.