Skip to content

Commit 1167d06

Browse files
committed
fix(cdk/collections): breaking changes for v20
Changes the deprecated APIs for v20 in `cdk/collections`. BREAKING CHANGE: * `SelectionModel.clear` now returns a boolean. * `SelectionModel.deselect` now returns a boolean. * `SelectionModel.select` now returns a boolean. * `SelectionModel.setSelection` now returns a boolean. * `SelectionModel.toggle` now returns a boolean.
1 parent c6144ec commit 1167d06

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/cdk/collections/selection-model.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class SelectionModel<T> {
5858
* Selects a value or an array of values.
5959
* @param values The values to select
6060
* @return Whether the selection changed as a result of this call
61-
* @breaking-change 16.0.0 make return type boolean
6261
*/
63-
select(...values: T[]): boolean | void {
62+
select(...values: T[]): boolean {
6463
this._verifyValueAssignment(values);
6564
values.forEach(value => this._markSelected(value));
6665
const changed = this._hasQueuedChanges();
@@ -72,9 +71,8 @@ export class SelectionModel<T> {
7271
* Deselects a value or an array of values.
7372
* @param values The values to deselect
7473
* @return Whether the selection changed as a result of this call
75-
* @breaking-change 16.0.0 make return type boolean
7674
*/
77-
deselect(...values: T[]): boolean | void {
75+
deselect(...values: T[]): boolean {
7876
this._verifyValueAssignment(values);
7977
values.forEach(value => this._unmarkSelected(value));
8078
const changed = this._hasQueuedChanges();
@@ -86,9 +84,8 @@ export class SelectionModel<T> {
8684
* Sets the selected values
8785
* @param values The new selected values
8886
* @return Whether the selection changed as a result of this call
89-
* @breaking-change 16.0.0 make return type boolean
9087
*/
91-
setSelection(...values: T[]): boolean | void {
88+
setSelection(...values: T[]): boolean {
9289
this._verifyValueAssignment(values);
9390
const oldValues = this.selected;
9491
const newSelectedSet = new Set(values.map(value => this._getConcreteValue(value)));
@@ -105,9 +102,8 @@ export class SelectionModel<T> {
105102
* Toggles a value between selected and deselected.
106103
* @param value The value to toggle
107104
* @return Whether the selection changed as a result of this call
108-
* @breaking-change 16.0.0 make return type boolean
109105
*/
110-
toggle(value: T): boolean | void {
106+
toggle(value: T): boolean {
111107
return this.isSelected(value) ? this.deselect(value) : this.select(value);
112108
}
113109

@@ -116,9 +112,8 @@ export class SelectionModel<T> {
116112
* @param flushEvent Whether to flush the changes in an event.
117113
* If false, the changes to the selection will be flushed along with the next event.
118114
* @return Whether the selection changed as a result of this call
119-
* @breaking-change 16.0.0 make return type boolean
120115
*/
121-
clear(flushEvent = true): boolean | void {
116+
clear(flushEvent = true): boolean {
122117
this._unmarkAll();
123118
const changed = this._hasQueuedChanges();
124119
if (flushEvent) {

tools/public_api_guard/cdk/collections.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ export interface SelectionChange<T> {
7373
export class SelectionModel<T> {
7474
constructor(_multiple?: boolean, initiallySelectedValues?: T[], _emitChanges?: boolean, compareWith?: ((o1: T, o2: T) => boolean) | undefined);
7575
readonly changed: Subject<SelectionChange<T>>;
76-
clear(flushEvent?: boolean): boolean | void;
76+
clear(flushEvent?: boolean): boolean;
7777
// (undocumented)
7878
compareWith?: ((o1: T, o2: T) => boolean) | undefined;
79-
deselect(...values: T[]): boolean | void;
79+
deselect(...values: T[]): boolean;
8080
hasValue(): boolean;
8181
isEmpty(): boolean;
8282
isMultipleSelection(): boolean;
8383
isSelected(value: T): boolean;
84-
select(...values: T[]): boolean | void;
84+
select(...values: T[]): boolean;
8585
get selected(): T[];
86-
setSelection(...values: T[]): boolean | void;
86+
setSelection(...values: T[]): boolean;
8787
sort(predicate?: (a: T, b: T) => number): void;
88-
toggle(value: T): boolean | void;
88+
toggle(value: T): boolean;
8989
}
9090

9191
// @public

0 commit comments

Comments
 (0)