-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor(javascript): type setTimeout in a way compatible with node & browser #527
Conversation
✅ Deploy Preview for api-clients-automation ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✗ The generated branch has been deleted.If the PR has been merged, you can check the generated code on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :D
@@ -54,7 +53,7 @@ export function createXhrRequester(): Requester { | |||
// istanbul ignore next | |||
if (baseRequester.status === 0) { | |||
clearTimeout(connectTimeout); | |||
clearTimeout(responseTimeout as NodeJS.Timeout); | |||
clearTimeout(responseTimeout!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a if to avoid having !
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not actually needed, clearTimeout accepts null and undefined too, just type types don't allow that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ty :D
… browser algolia/api-clients-automation#527 Co-authored-by: Haroen Viaene <hello@haroen.me>
🧭 What and Why
in node the output of setTimeout is NodeJS.Timeout, in browser it's number. This difference doesn't matter for us, and thus the return type can be used.
This allows us (if needed) to run the type checking with both node types enabled and disabled.
Changes included:
🧪 Test
TSC works