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

version 4.3.3 breaks TS/Angular/webpack #1957

Closed
slubowsky opened this issue Aug 24, 2023 · 2 comments · Fixed by #1958
Closed

version 4.3.3 breaks TS/Angular/webpack #1957

slubowsky opened this issue Aug 24, 2023 · 2 comments · Fixed by #1958

Comments

@slubowsky
Copy link

slubowsky commented Aug 24, 2023

App that compiles and runs using immutable 4.3.2, fails to start after upgrading to 4.3.3. Seems to be caused by #1932

Attempting to run app results in error:
Error: Failed to initialize Angular compilation - Maximum call stack size exceeded

To duplicate:

  1. Create an angular app - npx @angular/cli new TestApp (choose no routing and css)
  2. Install immutable 4.3.2 - npm i immutable@4.3.2
  3. In tsconfig.json change the value of noImplicitOverride option from true to false.
  4. Replace the contents of app.component.ts with the following (which kind of captures the problematic code in more or less the way its actually presenting):
import { Component } from '@angular/core';
import { /*DeepCopy,*/ List, Record } from 'immutable';

export interface Props {
  foos?: List<Foo>;
}

const defaults: Props = {
  foos: undefined // null
};

const fooRecord = Record(defaults, 'Foo');

export class Foo extends fooRecord implements Props {
  foos?: List<Foo>;
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'TestApp';

  // either of these causes issue
  // bar: DeepCopy<Foo>;
  bar = List<Foo>([new Foo()]).toJS();
}
  1. Run the app - npm start. It starts as expected.
  2. Upgrade to immutable 4.3.3 - npm i immutable@4.3.3
  3. Run the app - npm start. App fails to start with Error: Failed to initialize Angular compilation - Maximum call stack size exceeded

If line 15 - foos?: List<Foo>; is commented out we get a more descriptive error:

Error: src/app/app.component.ts:28:3 - error TS2615: Type of property 'foos' circularly references itself in mapped type '{ [ObjectKey in keyof Props]: DeepCopy<Props[ObjectKey]>; }'.
28   bar = List<Foo>([new Foo()]).toJS();
@slubowsky slubowsky changed the title version 4.3.3 breaks angular/webpack version 4.3.3 breaks TS/Angular/webpack Aug 25, 2023
@jdeniau
Copy link
Member

jdeniau commented Aug 25, 2023

Thanks @slubowsky , I partially reverted 4.3.3.

It should fix the circular reference issue you have (while loosing a better typing sadly :/ )

@slubowsky
Copy link
Author

@jdeniau Yes, version 4.3.4 works again. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants