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

Extracted CellMeasurer public interface #1058

Merged
merged 5 commits into from
Apr 7, 2018
Merged

Conversation

diogofcunha
Copy link
Contributor

Fixes #1026.

@bvaughn not totally confident about flow typings as I'm honestly not aware of best practices, shall we copy the types for the CellMeasurer as it's done for WindowScroller so that they can be pulled with the module and users can implement the interface or it's there anything I'm not aware of.

@@ -1,7 +1,7 @@
/** @flow */
import * as React from 'react';
import {findDOMNode} from 'react-dom';
import CellMeasurerCache from './CellMeasurerCache.js';
import {CellMeasureCache} from './CellMeasurerCache.js';
Copy link
Owner

@bvaughn bvaughn Mar 17, 2018

Choose a reason for hiding this comment

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

This won't actually change the generated prop-types in any meaningful way:

// master
  cache:
    typeof _CellMeasurerCache2.default === "function"
      ? require("prop-types").instanceOf(_CellMeasurerCache2.default).isRequired
      : require("prop-types").any.isRequired,

// this branch
  cache:
    typeof _CellMeasurerCache.CellMeasureCache === "function"
      ? require("prop-types").instanceOf(_CellMeasurerCache.CellMeasureCache)
          .isRequired
      : require("prop-types").any.isRequired

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made a few changes and the generated prop types now look like:
Will test it against react-virtualized-tree soon.

var babelPluginFlowReactPropTypes_proptype_CellMeasureCache = require('./types').babelPluginFlowReactPropTypes_proptype_CellMeasureCache || require('prop-types').any;

// ...
cache:
  typeof babelPluginFlowReactPropTypes_proptype_CellMeasureCache === 'function' 
    ? babelPluginFlowReactPropTypes_proptype_CellMeasureCache.isRequired 
      ? babelPluginFlowReactPropTypes_proptype_CellMeasureCache.isRequired 
      : babelPluginFlowReactPropTypes_proptype_CellMeasureCache 
    : require('proptypes').shape(babelPluginFlowReactPropTypes_proptype_CellMeasureCache).isRequired

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bvaughn our current version of babel-plugin-flow-react-proptypes is far behind (^13.0.0) when the package is on 21.0.0.

Interface support was added in 17.0.0 (brigand/babel-plugin-flow-react-proptypes#175), with the current version the propType for the interface is not being generated, causing the generated types.js to be empty.

Is there any know blocker in updating the package or can I go for that?

Copy link
Contributor

@TrySound TrySound Mar 17, 2018

Choose a reason for hiding this comment

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

I upgraded it some time ago and published 5 broken releases trying to fix its issues. We can try again.

Copy link
Contributor Author

@diogofcunha diogofcunha Mar 17, 2018

Choose a reason for hiding this comment

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

Thanks @TrySound, was checking the release history and can see we tried to update to 15.0.0 at the time, were our issues caused by this bug (brigand/babel-plugin-flow-react-proptypes@890c166) fixed in 16.0.0 release?

This issue (#991) opened at the time suggests it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will probably just cherry pick your original commit and change the version to the latest

Copy link
Contributor

Choose a reason for hiding this comment

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

There was a few issues. I guess they are fixed now. I'm gonna land it after rollup integration.

Copy link
Contributor Author

@diogofcunha diogofcunha Mar 17, 2018

Choose a reason for hiding this comment

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

I have good news, tried to upgrade and all seems good on rv side, the build output seems to be converting flow types to propTypes correctly, this includes interfaces.

Will use a local npm link to test it against https://github.com/diogofcunha/react-virtualized-tree. If it works there I guess it's good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested this and after adding useESModules flag everything seems to be working fine for babel-plugin-flow-react-proptypes update, no tests were broken and I can't see any runtime errors.

Tomorrow will try to add a custom cache just to make sure the original issue gets resolved.

.babelrc.js Outdated
@@ -1,4 +1,4 @@
const env = process.env.NODE_ENV;
const env = process.env.NODE_ENV;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove spaces

Copy link
Owner

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

This change looks good to me. Thanks for your patience.

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

Successfully merging this pull request may close these issues.

3 participants