Skip to content

Negative numbers as default values are not parsed #62

@flash1293

Description

@flash1293

If a negative number is defined as the default prop value, it is ignored in the styleguidist output, e.g.

interface TestProps {
  numProp: number;
}
export Test extends React.Component<TestProps, {}> {
  static defaultProps: TestProps = {
    numProp: -1
  };
 //...

This is due to the parsing in parser.ts#getLiteralValueFromPropertyAssignment - the switch-case-block handles SyntaxKind.NumericLiteral, but the - from -1 is passed as SyntaxKind.PrefixUnaryExpression

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions