Skip to content
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

ES2020 not supported when using Angular 15 #26554

Open
AStoker opened this issue Apr 20, 2023 · 5 comments
Open

ES2020 not supported when using Angular 15 #26554

AStoker opened this issue Apr 20, 2023 · 5 comments
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist

Comments

@AStoker
Copy link

AStoker commented Apr 20, 2023

Current behavior

Private fields have been supported by both Typescript and Javascript for a while now. However, when I try to use private fields inside my project, running cypress gives the error:

Module parse failed: Unexpected character '#'

The error spawns from

AppData/Local/Cypress/Cache/12.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/ts-loader/index.js
...
AppData\Local\Cypress\Cache\12.10.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-preprocessor\dist\index.js:212:23

The code it's failing on looks like this:

export class Interval {
  // Private fields
  #hours: number;
  #minutes: number;
  #seconds: number;
   ...

This project is created from Nx, and is the generic Angular application with Cypress. I created a simple repro repo here: https://github.com/AStoker/cypress-modern-es-tests

Desired behavior

Cypress should support private fields.

Test code to reproduce

Here is a repro: https://github.com/AStoker/cypress-modern-es-tests

Cypress Version

12.10.0

Node version

18.15.0

Operating System

Windows 11

Debug Logs

No response

Other

No response

@nagash77 nagash77 added the type: feature New feature that does not currently exist label Apr 21, 2023
@AStoker
Copy link
Author

AStoker commented Apr 21, 2023

Additional details. Attempted to make basic angular 14 project with cypress. That succeeded. Then upgraded to angular 15, and now it breaks with the same problem.
https://github.com/AStoker/angular-cypress-test

@AStoker AStoker changed the title Private Fields not supported Private Fields not supported when using Angular 15 Apr 21, 2023
@jordanpowell88 jordanpowell88 self-assigned this Apr 21, 2023
@AStoker
Copy link
Author

AStoker commented Apr 24, 2023

Some more details. My guess it revolves around whatever Cypress is using to read the output of the project. If you change the tsconfig target to ES2020 (rather than the updated ES2022 that comes default with Angular 15), things start working again.

@AStoker
Copy link
Author

AStoker commented Apr 24, 2023

Alas, spoke too soon. As even though I changed the target and that resolved the private fields, optional chaining still fails. Updating the repo to show this.

@jordanpowell88
Copy link
Collaborator

Thanks @AStoker for creating the issue and providing the reproducible repo. I'm able to reproduce this issue as well using your example repo. We will see what needs to be done to support this

@jordanpowell88 jordanpowell88 added Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. E2E Issue related to end-to-end testing labels Apr 24, 2023
@jordanpowell88 jordanpowell88 removed their assignment Apr 24, 2023
@AStoker AStoker changed the title Private Fields not supported when using Angular 15 ES2020 not supported when using Angular 15 Apr 26, 2023
@AStoker
Copy link
Author

AStoker commented Apr 26, 2023

Adding details for others who might be experiencing the issue. Part of the issue seems to be a bug in an older version of ts-loader (TypeStrong/ts-loader#1289).
A temporary workaround for now is to downgrade your tsconfig target down to ES2019 so that things get properly transpiled to a version ts-loader can work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

3 participants