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

The prop value with an expression type of JSXEmptyExpression could not be resolved. #125

Closed
quisido opened this issue Jan 26, 2023 · 7 comments

Comments

@quisido
Copy link

quisido commented Jan 26, 2023

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)
@ljharb
Copy link
Member

ljharb commented Jan 26, 2023

Can you share the code that this crashed on?

@quisido
Copy link
Author

quisido commented Jan 26, 2023

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.

@ljharb
Copy link
Member

ljharb commented Jan 26, 2023

So you can't reproduce the crash anymore?

@quisido
Copy link
Author

quisido commented Jan 26, 2023

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.

@ljharb
Copy link
Member

ljharb commented Jan 26, 2023

Unfortunately the snippet above doesn't seem to parse.

@ljharb
Copy link
Member

ljharb commented Jan 26, 2023

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?

@ljharb
Copy link
Member

ljharb commented Jan 26, 2023

This also seems like the same as #107, so I'll close, unless we can reproduce it. Thanks for filing!

@ljharb ljharb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2023
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jan 26, 2023
ljharb added a commit to jsx-eslint/eslint-plugin-react that referenced this issue Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants