-
Notifications
You must be signed in to change notification settings - Fork 40
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
When Plato is parsing Javascript that is using the elvis operator '?' it throws exceptions #116
Comments
Do you have any luck with this? |
Works for us under ESLint rules: .eslintrc.js parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
allowImportExportEverywhere: true,
ecmaFeatures: {
jsx: true,
impliedStrict: true,
},
}, and it might also be necessary to update your babel.config.js "plugins": [
"@babel/plugin-proposal-optional-chaining",
] Technically that If that doesn't do the trick I can look through our config a bit more to try to figure out if there's something we've added to handle this. |
could be related to #108 , which was also about the "elvis operator"/ optional chaning |
I've added a bit to that proposed remedy. I'm guessing that the Whatever the issue, something in our config definitely fixes it and I'm happy to help anyone get it working. The only thing in our codebase that really trips the parser up is that we use top level await. |
@slapbox are you using rollup with that, or webpack 5? For a long time top level wasn't really worth supporting because even if you parsed it, couldn't use it. Decorators have also had a tumultuous history as well. |
Webpack 5 here. Honestly it's still kind of a pain even for us, but less painful than writing self-executing async functions. There's no way they were worth using before this year. You probably already know that Webpack@5.x supports them via its "experiments.". Strangely, for all the errors ES6-Plato throws while parsing code containing top level awaits, it still seems to complete fine. I need to check the output for one of those specific files when I can though and report back. We only use top-level in a couple files. |
Hmmm... Our "fix" may not actually work. Looks like it still fails to parse those files. I'm honestly not sure how I could have overlooked it, but I can't get it working by moving backwards in our commit history so I have to assume human error here. |
I fixed by replace "typhonjs-escomplex": "0.0.12" with "typhonjs-escomplex": "0.1.0". @slapbox |
return nounDict[freq?.toLowerCase()];
the following javascript cannot be parsed.
I will try an update the packages to the latest versions.
I have the feeling it will fix it.
ta
The text was updated successfully, but these errors were encountered: