An issue arose with the usage of the experimental syntax 'optionalChaining' as it is currently not enabled
Encountering the error mentioned above led me to this helpful thread, where I followed the advice to include
"@babel/plugin-proposal-optional-chaining": "^7.7.4"
in my devDependencies
.
However, a new error surfaced after making this addition,
To resolve this issue, add @babel/plugin-proposal-optional-chaining () to your Babel configuration's 'plugins' section for transformation to take place.
Following another insightful post, I included a .babelrc
file at the root of my project
{
"presets": ["react", "es2015","stage-1"],
"plugins": ["transform-runtime", "transform-optional-chaining"]
}
Regrettably, this did not resolve my issue. Upon further investigation, I discovered that Create React App
restricts modifications to babel configurations. This prompted me to seek an alternative solution for enabling optional chaining without altering the entire CRA
setup.
P.S. My current environment includes "typescript": "^3.7.2"
according to my package.json
. Although I have executed npm install
to ensure the latest version is installed, there may be conflicting versions at play within the CRA
setup.
EDIT:
Upon inception of the project using CRA
, we were utilizing TypeScript: 3.6.x
. Seeking to leverage Optional Chaining
, I updated my package.json
to include "typescript": "^3.7.2"
followed by a npm install
command. The challenge arises from the discrepancy between the TypeScript
version specified and the existing configuration within CRA
, leaving me uncertain on how to proceed with updating.