stream-chat-js icon indicating copy to clipboard operation
stream-chat-js copied to clipboard

Fix tsc errors related to error type checking

Open pzmudzinski opened this issue 3 years ago • 3 comments

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 avatar Jan 20 '23 11:01 pzmudzinski

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

vanGalilea avatar Jan 27 '23 09:01 vanGalilea

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

vanGalilea avatar May 11 '23 07:05 vanGalilea

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

pzmudzinski avatar May 26 '23 13:05 pzmudzinski

Closing the PR as the root cause of the issue (#1062) was incorrect import that lead to tsc compiling node_modules.

MartinCupela avatar Sep 02 '24 08:09 MartinCupela