Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tsc errors related to error type checking #1091

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pzmudzinski
Copy link
Contributor

CLA

  • I have signed the Stream CLA (required).
  • 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

@vanGalilea
Copy link
Contributor

@pzmudzinski thanks for your contribution, we will take some time to review and test your PR and get back to you.

@vanGalilea
Copy link
Contributor

@pzmudzinski please have a look and fix linting issues ;)

@pzmudzinski
Copy link
Contributor Author

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants