Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

regression v8.2.2: optional chained properties reported as undefined #595

Closed
dnalborczyk opened this issue Feb 21, 2018 · 27 comments · Fixed by #630
Closed

regression v8.2.2: optional chained properties reported as undefined #595

dnalborczyk opened this issue Feb 21, 2018 · 27 comments · Fixed by #630

Comments

@dnalborczyk
Copy link

it appears that v8.2.2 is reporting optional chained properties as undefined (works with v8.2.1)

foo?.bar?.foobar
77:15  error  'bar' is not defined     no-undef
77:22  error  'foobar' is not defined  no-undef
@bciach
Copy link

bciach commented Feb 24, 2018

I approached same issue however I am using "babel-eslint": "^8.2.1" together with "@babel/plugin-proposal-optional-chaining": "^7.0.0-beta.40". @dnalborczyk could you please tell me what babel plugin you are using? Thanks in advance.

@lordgiotto
Copy link

lordgiotto commented Feb 25, 2018

I'm facing the same issue.
I'm using @babel/plugin-proposal-optional-chaining

Thanks for your great work ;)

@lehni
Copy link

lehni commented Feb 28, 2018

I am seeing this too. Downgrading back to 8.2.1 resolves the issue for me.

@existentialism
Copy link
Member

Ref: babel/babel#7288

We need to now handle OptionalMemberExpressions and OptionalCallExpressions.

Added this to my TODO list if no one gets to it first!

@julien-f
Copy link

julien-f commented Apr 5, 2018

@existentialism babel/babel#7288 has been resolved, does this mean this can be fixed?

@existentialism
Copy link
Member

@julien-f yes, my reference to it was more that it is the cause of the issue, not that I was waiting for it to land. Sorry for not being clear!

@lehni
Copy link

lehni commented Apr 15, 2018

Not a surprise given the state of discussions, but just to prevent other from having to test it:

8.2.3 still suffers from this issue.

@conradoramalho
Copy link

conradoramalho commented May 4, 2018

I downgrade 8.2.1 and this doesn't solves the problem for me. How did you fix it?

@brneto
Copy link

brneto commented May 5, 2018

I'm using:

ESLint: 4.19.1
Babel: 7.0.0-beta.46
babel-eslint: 8.2.3
@babel/plugin-proposal-optional-chaining: 7.0.0-beta.46

And I having the same issue here.

Have someone found how to solver that?

@gastonmorixe
Copy link

hours on this... downgrading to 8.2.1 works for me. Thanks

@hansonw
Copy link

hansonw commented May 24, 2018

It seems like this should be fixed once the babylon dep (@babel/parser now) is upgraded past beta45 (which includes babel/babel#7668). Right now it's at beta44.

Should be a pretty easy bump, is anyone working on this already (@hzoo?)

@lehni
Copy link

lehni commented May 25, 2018

@hansonw that alone doesn't seem to fix it. I just tried by installing and linking babel-eslint locally, and upgrading its dependencies. I still get the same linting errors with its @babel dependencies updated to beta.48

@brneto
Copy link

brneto commented May 26, 2018

In fact, downgrading to 8.2.1 have worked. Any idea when this issue will be fixed in next releases?

@brneto
Copy link

brneto commented Jun 1, 2018

@lehni have you tried with beta.49?

@richardgirges
Copy link

I'm seeing it with beta.49. I too had to downgrade to 8.2.1

@brneto
Copy link

brneto commented Jun 4, 2018

@richardgirges Have you seen with beta.49? Did Work?

@LennyPenny
Copy link

Even downgrading to 8.2.1 doesn't fix this for me

@brneto
Copy link

brneto commented Jun 4, 2018

We need the see your .babelrc and .eslintrc, at least.

@davidsmorais
Copy link

Downgraded to 8.2.1 and I got rid of the 'undefined' errors. Now it seems to be expecting a ternary (probably due to the '?').

Here are my dependencies

    "@babel/core": "^7.0.0-beta.49",
    "@babel/plugin-proposal-optional-chaining": "^7.0.0-beta.49",
    "@babel/plugin-syntax-optional-chaining": "^7.0.0-beta.49",
    "@babel/polyfill": "^7.0.0-beta.49",
    "@babel/preset-env": "^7.0.0-beta.49",
    "@babel/preset-react": "^7.0.0-beta.49",
    "babel-eslint": "^8.2.1",
    "babel-loader": "^8.0.0-beta.3",
    "eslint": "^4.19.1",

My .babelrc and .eslintrc, respectively

{
  "presets": [
    "@babel/react",
    "@babel/preset-env"
  ],
  "plugins": [
    "@babel/plugin-proposal-optional-chaining",
    "react-hot-loader/babel"
  ]
}
{
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "es6": true
  },
  "extends": ["eslint:recommended", "airbnb"],
  "parserOptions": {
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true,
      "jsx": true
    },
    "sourceType": "module"
  },
  "plugins": ["react", "jsx-a11y", "import"],
  "rules": { ... }

@LennyPenny
Copy link

@brneto
.babelrc

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "targets": {
                    "node": "current"
                }
            }
        ]
    ],
    "sourceMaps": "inline",
    "plugins": [
        "@babel/plugin-proposal-optional-chaining",
        "import-glob"
    ]
}

.eslintrc

{
    "parser": "babel-eslint",
    "env": {
        "es6": true,
        "node": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "module"
    },
    "rules": {...}
}

@brneto
Copy link

brneto commented Jun 8, 2018

@LennyPenny Are you importing @babel/polyfill at the root of your code? Are you using webpack or node as the environment to run your code?

@rubennorte
Copy link
Contributor

@existentialism I guess I got to it first. Can you please take a look at #630 where I put a fix for this? This is the last thing we need in order to roll out this at Facebook. Thanks!

@LennyPenny
Copy link

@brneto I'm using node with the latest babel. I never needed @babel/polyfill before, but even with it it doesn't work

@lehni
Copy link

lehni commented Jul 4, 2018

Unfortunately we're not out of the woods yet: #643

@jlaustill
Copy link

@lehni What is the process of helping with this? I'd like to get to a point that I can use optional chaining with eslint and cra@next, but I'm not sure how to plug in to help.

@lehni
Copy link

lehni commented Aug 18, 2018

@jlaustill I don't know! I haven't been involved in fixing those issues, just been observing them and pointing them out.

@macrozone
Copy link

even with assigments this error gets thrown using babel-eslint 9.0.0 final

#643 (comment)

downgrading to 8.2.1 solves it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.