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

typescript(vx-responsive): re-write package in TypeScript #517

Merged
merged 12 commits into from Oct 9, 2019

Conversation

Rudeg
Copy link

@Rudeg Rudeg commented Sep 24, 2019

🚀 Enhancements

This PR builds off of #488 which added TypeScript build support, and converts the @vx/responsive package to TypeScript.

Closes #514.

Testing

  • CI
  • Generates .d.ts files

@williaster @hshoff @schillerk @milesj @kristw

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

Thanks for converting this one! it's perhaps one of our most-used packages 😎 Had a couple comments on it.

packages/vx-responsive/src/components/ParentSize.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/components/ParentSize.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/components/ParentSize.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/components/ScaleSVG.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/components/ScaleSVG.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/enhancers/withScreenSize.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/enhancers/withParentSize.tsx Outdated Show resolved Hide resolved
packages/vx-responsive/src/components/ParentSize.tsx Outdated Show resolved Hide resolved
@Rudeg
Copy link
Author

Rudeg commented Sep 25, 2019

@williaster Thanks for the review! Should be good now :)

};

animationFrameID: number | null;
ro: ResizeObserver | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to use more verbose name?

const { parentWidth, parentHeight } = this.state;
return (
<div
style={{ width: '100%', height: '100%' }}
Copy link
Collaborator

@kristw kristw Oct 2, 2019

Choose a reason for hiding this comment

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

Convert to constant.
Note: This 100% style is known to create a layout bug that leave some area of the screen empty when the children use less than 100% width or height, e.g. 50% width & 50% height. This is because this div always secure 100% width & height bounding box in the layout.

window.removeEventListener('resize', this.handleResize, false);
}

resize(/** event */) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use arrow function for binding?

if (this.ro) this.ro.disconnect();
}

resize({ width, height }: { width: number; height: number }) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use arrow function for binding?

@williaster
Copy link
Collaborator

looks like we might need to add types for ResizeObserver microsoft/TypeScript#28502

also, updated base branch to master.

@williaster williaster changed the base branch from chris--typescript to master October 4, 2019 20:49
@Rudeg
Copy link
Author

Rudeg commented Oct 7, 2019

@williaster I bumped resize-observer-polyfill to the 1.5.1 version, and it solved a problem with types. However, I'm getting lint error on no-undef for the type export. This rule produce false-positives for the TS instances like types and interfaces

@williaster
Copy link
Collaborator

williaster commented Oct 7, 2019

Hrmm, that's strange 🙈 Do you think it'd be fixable by changing the syntax to something like

export type ParentSizeProvidedProps = ParentSizeState;

instead of

export { ParentSizeState as ParentSizeProvidedProps }?

@Rudeg
Copy link
Author

Rudeg commented Oct 7, 2019

@williaster that will work, thanks! Should be fixed now:)

Copy link
Collaborator

@williaster williaster left a comment

Choose a reason for hiding this comment

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

dope!

@hshoff hshoff added this to In progress in TypeScript via automation Oct 9, 2019
@hshoff hshoff added this to the v0.0.193 milestone Oct 9, 2019
TypeScript automation moved this from In progress to Reviewer approved Oct 9, 2019
@hshoff hshoff merged commit 3b8291e into airbnb:master Oct 9, 2019
TypeScript automation moved this from Reviewer approved to Done Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
TypeScript
  
Done
Development

Successfully merging this pull request may close these issues.

Re-write @vx/vx-responsive in TypeScript
4 participants