Skip to content

Commit 62d75d0

Browse files
committed
feat(material/table): accept undefined sort and paginator
Extend types of the sort and paginator setter to include undefined to avoid `?? null` when using singals (e.g. `viewChild`).
1 parent a62164d commit 62d75d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/material/table/table-data-source.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ export class MatTableDataSource<T, P extends MatPaginator = MatPaginator> extend
107107
return this._sort;
108108
}
109109

110-
set sort(sort: MatSort | null) {
111-
this._sort = sort;
110+
set sort(sort: MatSort | null | undefined) {
111+
// Treat undefined like the initial this._sort value.
112+
// Note that the API can be changed in a breaking change to fix the cast.
113+
this._sort = sort as MatSort | null;
112114
this._updateChangeSubscription();
113115
}
114116

@@ -128,8 +130,10 @@ export class MatTableDataSource<T, P extends MatPaginator = MatPaginator> extend
128130
return this._paginator;
129131
}
130132

131-
set paginator(paginator: P | null) {
132-
this._paginator = paginator;
133+
set paginator(paginator: P | null | undefined) {
134+
// Treat undefined like the initial this._paginator value.
135+
// Note that the API can be changed in a breaking change to fix the cast.
136+
this._paginator = paginator as P | null;
133137
this._updateChangeSubscription();
134138
}
135139

0 commit comments

Comments
 (0)