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

Build: Migrate @storybook/channel-websocket to strict TS #22364

Merged

Conversation

EDuToit
Copy link
Contributor

@EDuToit EDuToit commented May 2, 2023

Closes #

What I did

Migrate @storybook/channel-websocket to strict-ts

How to test

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@kasperpeulen kasperpeulen self-assigned this May 3, 2023
@kasperpeulen kasperpeulen self-requested a review May 3, 2023 10:42
Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I left some feedback :)

@@ -20,9 +20,9 @@ interface CreateChannelArgs {
}

export class WebsocketTransport {
private socket: WebSocket;
private socket?: WebSocket;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer inlining the connect function in the constructor, to show TS that it is always defined. As it is private, it is really only used in the constructor anyway.

Comment on lines 72 to 74
if (this.handler) {
this.handler(event);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we expect a handler to be set here. Could you do a runtime assertion with tiny-invariant?

invariant(this.handler, "WebsocketTransport handler should be set");

@kasperpeulen kasperpeulen added the maintenance User-facing maintenance tasks label May 3, 2023
Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rolled bock one socket null check that is not neccesary anymore, LGTM now!

@kasperpeulen kasperpeulen merged commit 67a8d08 into storybookjs:next May 4, 2023
@EDuToit
Copy link
Contributor Author

EDuToit commented May 4, 2023

#22176

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

Successfully merging this pull request may close these issues.

None yet

2 participants