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

Negative numbers as default values are not parsed #62

Closed
flash1293 opened this issue Jan 18, 2018 · 1 comment
Closed

Negative numbers as default values are not parsed #62

flash1293 opened this issue Jan 18, 2018 · 1 comment

Comments

@flash1293
Copy link

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

@pvasek
Copy link
Collaborator

pvasek commented Jan 22, 2018

Thanks to @dotcs fixed in version v1.2.3.

@pvasek pvasek closed this as completed Jan 22, 2018
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

2 participants