Description
The constructor parameters of CdkTable changed in version 10.1.2 (see: 10.1.1...10.1.2#diff-86c33ad9a24e48674baaf250f4035a11).
This issue might be not considered a bug if we do not assume CDK components API is something that should conform semver versioning.
However, in my opinion, parameters of a public constructor should be rather treated as a part of the public API. Especially for a CDK, which is meant to be used and extended by others. Thus such a breaking change should be done in major versions only according to the semver standard.
The particular breaking change:
71a2a17#diff-86c33ad9a24e48674baaf250f4035a11R430
The change causes our Barista library to fail the compilation. However, I've originally spotted the problem during development of our product that uses the Barista lib and it was much more cumbersome, because there was no compilation error - the library was already prebuilt and the only error that we got was a runtime one (both Jest and browser):
TypeError: Cannot read property 'nativeElement' of null
at DtTable.CdkTable (../src/cdk/table/table.ts:442:24)
at DtTable._DtTableBase [as constructor] (libs/barista-components/table/src/base-table.ts:64:5)
at new DtTable (libs/barista-components/table/src/table.ts:166:5)
at createClass (../packages/core/src/view/provider.ts:290:7)
at createDirectiveInstance (../packages/core/src/view/provider.ts:142:7)
at createViewNodes (../packages/core/src/view/view.ts:314:28)
at callViewAction (../packages/core/src/view/view.ts:647:7)
at execComponentViewsAction (../packages/core/src/view/view.ts:570:7)
at createViewNodes (../packages/core/src/view/view.ts:342:3)
at createRootView (../packages/core/src/view/view.ts:216:3)
at callWithDebugContext (../packages/core/src/view/services.ts:638:23)
at Object.debugCreateRootView [as createRootView] (../packages/core/src/view/services.ts:119:10)
at ComponentFactory_.create (../packages/core/src/view/refs.ts:92:27)
at initComponent (../packages/core/testing/src/test_bed.ts:618:28)
at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
at ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Object.onInvoke (../packages/core/src/zone/ng_zone.ts:326:29)
at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Zone.run (node_modules/zone.js/dist/zone.js:143:47)
at NgZone.run (../packages/core/src/zone/ng_zone.ts:180:50)
at TestBedViewEngine.createComponent (../packages/core/testing/src/test_bed.ts:622:56)
at Function.TestBedViewEngine.createComponent (../packages/core/testing/src/test_bed.ts:245:36)
at libs/cmc/home/feature/src/lib/network-zones/details/table/cmc-network-zone-details-table.component.spec.ts:92:23
at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
at ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
at Zone.run (node_modules/zone.js/dist/zone.js:143:47)
As far as I researched, a similar issue was closed: #20308, however Angular 10.0.10 doesn't seem to solve this specific issue.
Reproduction
Real world reproduction example:
- Clone our open source component library: https://github.com/dynatrace-oss/barista
- Install dependencies and build it:
npm install && npm run build
The build should pass fine. - Update the
@angular/cdk
dependency - Re-install dependencies and rebuild it - the build will fail:
ERROR in libs/barista-components/table/src/base-table.ts:64:5 - error TS2554: Expected 8 arguments, but got 7.
64 super(
65 differs,
...
71 platform,
72 );
It can be easily reproduced with a Stackblitz example as well. Please, let me know if you'd like that. Although, I don't think it's necessary - the issue can be easily spotted even with a static analysis.
Expected Behavior
Patch version should not contain API breaking changes.
Actual Behavior
The constructor parameter change causes compilation errors in the library using the CDK directly, and runtime errors for projects using it indirectly by a precompiled dependency.
Environment
- Angular: 10.0.12
- CDK/Material: 10.1.3
- Browser(s): N/A
- Operating System (e.g. Windows, macOS, Ubuntu): N/A