Optional chaining issue
See original GitHub issueHey,
I added a .babelrc to the .storybook directory, installed babel-plugin-transform-optional-chaining, and added this to the .babelrc.
{
"presets": ["env", "stage-0", "react"],
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}],
"transform-optional-chaining"
]
}
The above config is just lifted from the one in the storybook repo. I played around and experimented with a few different solutions but I couldn’t get it to work. On each load it would see the use of obj?.prop?.otherProp and throw Module build failed: SyntaxError: Unexpected token.
package.json
"dependencies": {
"@storybook/react": "^3.2.12",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"styled-components": "^2.2.1"
},
"devDependencies": {
"babel-plugin-transform-optional-chaining": "^7.0.0-alpha.13.1",
"eslint": "^4.8.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0",
"prettier": "^1.7.4"
}
I’m hoping it’s something simple I’m missing as it would be a very useful feature for my current project. Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
What is wrong with optional chaining and how to fix it - DEV ...
In other words optional chaining has a problem with dealing with any computation which needs to be done on the result of it...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >Optional chaining '?.' - The Modern JavaScript Tutorial
The optional chaining ?. is a safe way to access nested object properties, even if an intermediate property doesn't exist.
Read more >How to Use Optional Chaining in JavaScript - freeCodeCamp
Optional chaining is a safe and concise way to perform access checks for nested object properties. The optional chaining operator ?. takes ...
Read more >Optional chaining of unknown should be unknown #37700
Currently it is forbidden to use optional chaining on unknown . But for all possible types in JavaScript, optional chaining will return ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Hypnosphi any thoughts on this in 2020? 😅
@Hypnosphi we use custom webpack config, as i see plugin didn’t added to final webpack config.