react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

TypeError: Got unsupported definition type.

Open sombreroEnPuntas opened this issue 5 years ago • 0 comments

Issue when parsing a styled component react component

Compile warning

Getting the following warning:

Warning: Cannot parse src/components/Input.tsx: TypeError: Got unsupported definition type. Definition must be one of ObjectExpression, ClassDeclaration, ClassExpression,VariableDeclaration, ArrowFunctionExpression, FunctionExpression, TaggedTemplateExpression, FunctionDeclaration or CallExpression. Got "BinaryExpression" instead.

It usually means that react-docgen does not understand your source code, try to file an issue here:
https://github.com/reactjs/react-docgen/issues

Code to reproduce

It happens with the following code:

import styled from 'styled-components'

interface Props {
  status?: 'error' | 'success'
}

export const Input = styled.input<Props>`
  ${({ theme: { colors, fonts }, disabled, status }) => `
    background-color: ${
      disabled ? colors.disabled : colors[status || 'black'].background
    };
    border: none;
    box-shadow: 0 4px ${colors[status || 'black'].shadow},
      0 -4px ${colors[status || 'black'].shadow},
      4px 0 ${colors[status || 'black'].shadow},
      -4px 0 ${colors[status || 'black'].shadow};
    font-family: ${fonts.fontFamily};
    line-height: calc(2 * ${fonts.lineHeight});
    margin: 4px;
    outline-color: ${colors[status || 'black'].outline};
    padding: 0.5rem 1rem;
    `}
`

// shouldn't this annotation be enough?
/** @component */
export default Input

I use "[email protected]" thru "react-styleguidist": "^10.4.0"

Full repo --> https://github.com/sombreroEnPuntas/retro-ui

Expected

Not sure if the issue comes from the annotation or just unsupported libs :)

sombreroEnPuntas avatar Mar 08 '20 15:03 sombreroEnPuntas