Skip to content

Circular dependency between base-widget.ts and gridstack.component.ts #2955

@d-luitwieler-anva

Description

@d-luitwieler-anva

There is a circular dependency between gridstack.component.ts and base-widget.ts, which in some scenarios will lead to errors. One of those scenario's can be found in the example below where we cannot extend from BaseWidget.
Worth mentioning is that we have other unit tests and other code in the same codebase that extend BaseWidget without any problems.

The issue was discovered in version 11.3.0, but has likely existed long before.

Example.

test-base-widget.spec.ts (jest unit test)

import { BaseWidget } from 'gridstack/dist/angular';

class TestComponent extends BaseWidget {}

it('test', () => {
  // nothing
});

Running this unit test will throw the following error:

Image

We have seen similar weird issues in the past with other code that were eventually tracked down to be caused by Circular Dependencies and often those circular dependencies had existed for a longer period of time, it just never manifested in errors before.

So it is just a matter of time before actual issues occur in other parts of a client's codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions