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

Migrate @storybook/channel-postmessage to TypeScript #5154

Merged
merged 2 commits into from Jan 7, 2019

Conversation

dandean
Copy link
Member

@dandean dandean commented Jan 6, 2019

Issue: #5030

What I did

Migrate @storybook/channel-postmessage to TypeScript

How to test

There are no existing tests for this module.

@dandean dandean added maintenance User-facing maintenance tasks core typescript labels Jan 6, 2019
@dandean dandean self-assigned this Jan 6, 2019
@dandean dandean requested a review from thani-sh as a code owner January 6, 2019 19:44
@codecov
Copy link

codecov bot commented Jan 7, 2019

Codecov Report

Merging #5154 into next will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #5154      +/-   ##
==========================================
- Coverage   35.25%   35.23%   -0.02%     
==========================================
  Files         596      596              
  Lines        7397     7401       +4     
  Branches     1010     1015       +5     
==========================================
  Hits         2608     2608              
- Misses       4276     4285       +9     
+ Partials      513      508       -5
Impacted Files Coverage Δ
lib/channel-postmessage/src/index.ts 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6602d2...f144a3c. Read the comment docs.

@ndelangen ndelangen merged commit dece5f0 into next Jan 7, 2019
@ndelangen ndelangen added this to the next milestone Jan 7, 2019
if (!iframeWindow) {
return new Promise((resolve, reject) => {
this._buffer.push({ event, resolve, reject });
this.buffer.push({ event, resolve, reject });
});
}
const data = stringify({ key: KEY, event });
iframeWindow.postMessage(data, '*');
return Promise.resolve(null);
Copy link
Member

Choose a reason for hiding this comment

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

return Promise.resolve(null) feels odd
In all return cases, the return value should be void right? This existed before your PR, I just thought this should be fixed because this return value is part of the public API now

@ndelangen what do you think?

Like this:

  send(event: ChannelEvent): Promise<void> {
    const iframeWindow = this.getWindow();
    if (!iframeWindow) {
      return new Promise((resolve, reject) => {
        this._buffer.push({ event, resolve, reject });
        this.buffer.push({ event, resolve, reject });
      });
    }
    const data = stringify({ key: KEY, event });
    iframeWindow.postMessage(data, '*');
    return Promise.resolve();
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm cool with whatever you and @ndelangen decide. Happy to make the patch if you want me to.

@ndelangen ndelangen deleted the ts-migration/channel-postmessage branch May 7, 2019 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants