arogozine / LinqToTypeScript

LINQ to TypeScript
https://arogozine.github.io/linqtotypescript/
MIT License
139 stars 18 forks source link

Node.js 20 LTS compatibility #28

Open ebiton-eig opened 10 months ago

ebiton-eig commented 10 months ago

LingToTypescript does not work with node.js 20 LTS.

Uncaught SyntaxError: Illegal continue statement: 'outerLoop' does not denote an iteration statement (at linq-to-typescript.js?v=09a07e09:3073:26)

arogozine commented 8 months ago

So, I've updated the tests to use Node 20.10.0 and they all ran without an issue.

How are you getting this error?

ebiton-eig commented 8 months ago

After more testing, the problem is with SSR enabled. It's easy to reproduce:

Create a new project Angular 17 with SSR enabled.

In the app.component.ts:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterOutlet } from '@angular/router';
import { from } from 'linq-to-typescript';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule, RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'test';
  test = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];

  constructor() {
    const result = from(this.test).any(x => x === `'a');`
    console.log(result);
  }
}

And the error when you build:

ng build

An unhandled exception occurred: Illegal continue statement: 't' does not denote an iteration statement
See "C:\Users\xxxx\AppData\Local\Temp\ng-ao6Efq\angular-errors.log" for further details.
[error] SyntaxError: Illegal continue statement: 't' does not denote an iteration statement
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:155:18)
    at callTranslator (node:internal/modules/esm/loader:285:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30)

No problem with an Angular 17 app without SSR enabled.

arogozine commented 8 months ago

Might be related to https://github.com/arogozine/LinqToTypeScript/issues/29

I wonder if Server-Side Rendering is trying to transpile down the async for loops with a continue outerLoop label and failing

ebiton-eig commented 7 months ago

No fix for this problem?