The prop value with an expression type of JSXEmptyExpression could not be resolved.
quisido opened this issue · 7 comments
The prop value with an expression type of JSXEmptyExpression could not be resolved.
ESLint stack trace:
TypeError: LITERAL_TYPES[value.type] is not a function
Occurred while linting /**/*.tsx:*
Rule: "react/button-has-type"
at getLiteralValue (/**/node_modules/jsx-ast-utils/lib/values/index.js:69:35)
Can you share the code that this crashed on?
I don't think I still have it, but it was something like this:
function MyComponent(): ReactElement {
const buttonProps: (Required<Attributes> & ButtonHTMLAttributes<HTMLButtonElement>)[]= [
{
children: 'test',
key: 'test',
onClick: (): void => {
return;
},
},
];
return <>
{
buttonProps.map(
({ key, ...props }: Required<Attributes> & ButtonHTMLAttributes<HTMLButtonElement>): ReactElement =>
<button key={key} type="button" {...props} />
}
</>;
}
key
may not have been destructured at the time of the crash, though; and the type
prop may have been missing.
Sorry that I can't provide an exact copy. Hope this helps.
So you can't reproduce the crash anymore?
I haven't tried. I have since fixed it in my codebase and do not have the opportunity to re-break it. I was hoping the information in the OP was enough.
<button {...props} />
where props
is Required<Attributes> & ButtonHTMLAttributes<HTMLButtonElement>
is as specific as I can be for the time being.
Unfortunately the snippet above doesn't seem to parse.
ok, i was able to fix the parse error, but it passes on the latest eslint-plugin-react. Are you sure you've got the latest version of that, and jsx-ast-utils, installed?