Skip to content

Not possible to use the spread operator to inherit Prop types #18

@IgorNovikov10

Description

@IgorNovikov10

Hi, we have a component that should inherit the prop types of another component, like this

FrontPageHero.propTypes = {
  ...HeroBaseModel.propTypes,
  lang: PropTypes.shape({
    originMattersLabel: PropTypes.string.isRequired,
  }).isRequired,
};

Object.assign syntax seems to work fine, but when using such a ES6 syntax, namely the spread operator, the view-models or actually eslint-plugin-view-models package throws an error and does not generate the required model

TypeError: Cannot read properties of undefined (reading 'name')
Occurred while linting      
Rule: "view-models/no-errors"

Is it possible to add spread operator support to avoid the error? Given the fact that the use of such syntax is allowed in the eslint-plugin-react module, according to this thread jsx-eslint/eslint-plugin-react#1541

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions