Skip to content

version 4.3.3 breaks TS/Angular/webpack #1957

Closed
@slubowsky

Description

@slubowsky

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();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions