carteb/carte-blanche

Support referenced and imported propTypes

tmc opened this issue ยท 7 comments

tmc commented

givent

import React from 'react';

const user = React.PropTypes.shape({
  email_address: React.PropTypes.string,
  name: React.PropTypes.string,
})

export default class Foobar extends React.Component {
  static propTypes = {
    a1: user,
    a2: React.PropTypes.shape({
      email_address: React.PropTypes.string,
      name: React.PropTypes.string,
    })
  };
  render() { return (<p>.</p>); }
};

the a1 field is renders to 'No Control available' while a2 appropriately renders the expected form.

Interesting, that's highly likely a limitation of react-docgen which we can't really work around. Maybe switching to recon will fix this?

/cc @chrisui, ref #293

tmc commented

Being in an environment in which I'm generating propTypes from an IDL this is a pretty important limitation.

Okay, let's wait for @chrisui to be back from holiday (soon?) and then we'll look into this! ๐Ÿ‘

Would be an interesting contribution to https://github.com/reactjs/react-docgen

@fkling I'm curious about your thoughts on how easy/hard this would be. I would be happy to dig in and submit a PR.

Potentially the same issue as reactjs/react-docgen#65 . Variables should be resolved. I guess one would just have to add a resolveToValue call here: https://github.com/reactjs/react-docgen/blob/master/src/handlers/propTypeHandler.js#L47

@fkling cool, thx for the hint. I will look into it later this week and create a PR ๐Ÿ˜Š

tmc commented

@fkling / @nikgraf that does appear to fix this, FWIW