Skip to content

Commit 122137a

Browse files
committed
refactor(multiple): Fix MatTableDataSource T type and accept goldens
1 parent 16eae10 commit 122137a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

goldens/material/table/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class MatTable<T> extends CdkTable<T> {
174174
}
175175

176176
// @public
177-
export class MatTableDataSource<T extends object | ArrayLike<unknown>, P extends MatPaginator = MatPaginator> extends DataSource<T> {
177+
export class MatTableDataSource<T extends object | any, P extends MatPaginator = MatPaginator> extends DataSource<T> {
178178
constructor(initialData?: T[]);
179179
connect(): BehaviorSubject<T[]>;
180180
get data(): T[];

goldens/material/tooltip/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
5353
set hideDelay(value: NumberInput);
5454
_isTooltipVisible(): boolean;
5555
get message(): string;
56-
set message(value: unknown);
56+
set message(value: string | number | null | undefined);
5757
// (undocumented)
5858
ngAfterViewInit(): void;
5959
ngOnDestroy(): void;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MAX_SAFE_INTEGER = 9007199254740991;
4242
*/
4343
export class MatTableDataSource<
4444
// TODO: Remove `any` type below in a breaking change:
45-
T extends object | ArrayLike<unknown> | any,
45+
T extends object | any,
4646
P extends MatPaginator = MatPaginator,
4747
> extends DataSource<T> {
4848
/** Stream that emits when a new data array is set on the data source. */
@@ -236,7 +236,10 @@ export class MatTableDataSource<
236236
// Transform the filter by converting it to lowercase and removing whitespace.
237237
const transformedFilter = filter.trim().toLowerCase();
238238
// Loops over the values in the array and returns true if any of them match the filter string
239-
return Object.values(data).some(value => `${value}`.toLowerCase().includes(transformedFilter));
239+
// TODO: Remove `as object` cast when `T` stops extending `any`:
240+
return Object.values(data as object).some(value =>
241+
`${value}`.toLowerCase().includes(transformedFilter),
242+
);
240243
};
241244

242245
constructor(initialData: T[] = []) {

0 commit comments

Comments
 (0)