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 OptionalMemberExpression could not be resolved #70

Closed
HsuTing opened this issue Aug 23, 2018 · 8 comments

Comments

@HsuTing
Copy link

HsuTing commented Aug 23, 2018

I use @babel/plugin-proposal-optional-chaining like this:

<div href={data?.href} />

I found only href will throw error. Other props will not throw error, like this:

<div test={data?.test} />
@pdong
Copy link

pdong commented Oct 10, 2018

I am seeing this with .title as well

{data?.title} will error out with

The prop value with an expression type of OptionalMemberExpression could not be resolved.
  Please file issue to get this fixed immediately.
Error: The prop value with an expression type of OptionalMemberExpression could not be resolved.
  Please file issue to get this fixed immediately.
    at Object.extractLiteral [as JSXExpressionContainer] (/Users/pdong/node_modules/jsx-ast-utils/lib/values/expressions/index.js:202:11)
    at getLiteralValue (/Users/pdong/node_modules/jsx-ast-utils/lib/values/index.js:61:35)
    at extractValue (/Users/pdong/node_modules/jsx-ast-utils/lib/getPropValue.js:24:12)
    at getLiteralPropValue (/Users/pdong/node_modules/jsx-ast-utils/lib/getPropValue.js:56:10)
    at JSXAttribute (/Users/pdong/node_modules/eslint-plugin-jsx-a11y/lib/rules/aria-proptypes.js:88:58)
    at listeners.(anonymous function).forEach.listener (/Users/pdong/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/pdong/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/pdong/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/pdong/node_modules/eslint/lib/util/node-event-generator.js:280:22)

but if I change it it works. 🤔

Wondering if this is broken for all valid html attrs maybe 🤷‍♂️

@jessebeach
Copy link
Collaborator

Working on it now. I need to update all the dev dependencies to get there :)

@HsuTing HsuTing closed this as completed Mar 18, 2019
@ljharb ljharb reopened this Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 18, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 23, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 23, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 23, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 24, 2019
[jsx-eslint#73] Account for SpreadElement AST Nodes

[jsx-eslint#70] Support OptionalMemberExpression AST nodes
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 24, 2019
jessebeach added a commit to jessebeach/jsx-ast-utils that referenced this issue Mar 24, 2019
jessebeach added a commit that referenced this issue Mar 24, 2019
[#70] Support OptionalMemberExpression AST nodes
@jessebeach
Copy link
Collaborator

@HsuTing , Fixed in version v2.2.1. This will log an error in the console, but it will no longer throw.

@HsuTing
Copy link
Author

HsuTing commented Jul 1, 2019

@jessebeach OK, thank for your help.

@MathiasKandelborg
Copy link

Could we not get this error? The message comes from here, following the issue trail from eslint.

If there is an error/bug, it should get fixed, if it's a false report, I don't want to see it.

@jessebeach
Copy link
Collaborator

@MathiasKandelborg I understand the frustration here. I feel it, too. I hate seeing these bugs pop up. I'll look into it this weekend and put out a patch release.

@ljharb
Copy link
Member

ljharb commented Oct 9, 2020

note that v3.0 of jsx-ast-utils is out, and eslint-plugin-jsx-a11y has been updated with it, but not yet released - so a patch release here would still need a release in eslint-plugin-jsx-a11y.

It's also possible this is already fixed in v3.0.

@ljharb
Copy link
Member

ljharb commented Oct 14, 2020

Pretty sure this is fixed by #77. eslint-pliugin-react has already been updated with it, and eslint-plugin-jsx-a11y will get it on the next release.

@ljharb ljharb closed this as completed Oct 14, 2020
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

5 participants