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

Props cannot extend from an interface using Pick #22

Closed
cwmacdon opened this issue Jun 8, 2017 · 2 comments
Closed

Props cannot extend from an interface using Pick #22

cwmacdon opened this issue Jun 8, 2017 · 2 comments

Comments

@cwmacdon
Copy link

cwmacdon commented Jun 8, 2017

The Pick operator allows us to specify a subset of properties from another interface. However this causes a parsing error in the file, and it crashes and fails to generate anything at all for this class.

export interface IButtonProps extends Pick<React.HTMLProps<HTMLInputElement>, 'onClick'|'type'> {
    icon?: string
}
export class Button extends React.PureComponent<IButtonProps, {}> {
    render() {
        const { type, onClick, icon } = this.props;
        return (
            <input type={type} onClick={onClick}>
                {this.props.icon
                    ? <i className={`fa fa-${icon}`} />
                    : null
                }
                {this.props.children}
            </input>
        );
    }
}

Gives the following error:

Error when parsing src/components/Button/Button.tsx: TypeError: Cannot read property 'parent' of undefined
@ESWAT
Copy link

ESWAT commented Sep 5, 2017

So I’ve ran into this issue with a very similar example. After some debugging I realized that parsing is fine when Pick is used for just one property, but using Pick for more than one element leads to an error.

EDIT: Using 1.0.0

pvasek added a commit to pvasek/react-docgen-typescript that referenced this issue Sep 8, 2017
pvasek added a commit to pvasek/react-docgen-typescript that referenced this issue Sep 8, 2017
pvasek added a commit to pvasek/react-docgen-typescript that referenced this issue Sep 8, 2017
pvasek added a commit that referenced this issue Sep 8, 2017
Props extended from Pick fails - #22 fixed
@pvasek
Copy link
Collaborator

pvasek commented Sep 9, 2017

Release v1.0.2 which has just been published should fix this issue.

@pvasek pvasek closed this as completed Sep 9, 2017
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

No branches or pull requests

3 participants