Optional chaining (?.) is not supported with "target": "esnext"
See original GitHub issueCurrent behavior
It’s impossible to use optional chaining if "target": "esnext"
is configured in tsconfig.json
.
In fact, I would like to reopen the issue #9298.
In tsconfig.json:
"target": "esnext",
In spec:
cy.visit(objectWithUrlInside?.url);
Error:
Webpack Compilation Error
./cypress/integration/spec.ts 7:37
Module parse failed: Unexpected token (7:37)
File was processed with these loaders:
* ../../../Users/mlegait/AppData/Local/Cypress/Cache/9.5.2/Cypress/resources/app/packages/server/node_modules/ts-loader/index.js
You may need an additional loader to handle the result of these loaders.
| url: "https://example.cypress.io",
| };
> cy.visit(objectWithUrlInside?.url);
| });
| });
GET /__cypress/tests?p=cypress%5Cintegration%5Cspec.ts 200 22.363 ms - -
Desired behavior
We should be able to use esnext
as target with Cypress and have optional chaining supported.
Test code to reproduce
https://github.com/mlegait/cypress-test-tiny
Cypress Version
9.5.2
Other
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:6 (3 by maintainers)
Top Results From Across the Web
ts-jest Optional Chaining not working if tsConfig Target as ...
But Node JS doesn't support conditional chaining by default yet. So on using the ES2019 as the target, it transpiles and works on...
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 >ts-jest Optional Chaining not working if tsConfig Target as ...
Coding example for the question ts-jest Optional Chaining not working if tsConfig Target as ESNext, ES2021 or ES2020-node.js.
Read more >babel/plugin-transform-typescript
Note that although the TypeScript compiler tsc actively supports certain JavaScript proposals such as optional chaining ( ?. ), nullish coalescing ( ??...
Read more >The Beauty of the Optional Chaining Operator (?.) in TypeScript
The optional chaining operator is supported all popular browsers except IE, Firefox for Android, Opera for Android and Samsung Browser.
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 FreeTop 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
Top GitHub Comments
@lmiller1990 @ZachJW34 any chance of supporting
es2020
,es2021
,es2022
,esnext
and other newer values?I documented some workarounds over here: https://github.com/cypress-io/cypress/issues/16914#issuecomment-1179996139