Skip to content

Commit dabbf3e

Browse files
committed
refactor(material/table): fix strict property initialization errors
Updates the code to be compatible with strict property initialization.
1 parent 75b5cbb commit dabbf3e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ describe('MatTableDataSource', () => {
8888
imports: [MatSortModule],
8989
})
9090
class MatSortApp {
91-
@ViewChild(MatSort, {static: true}) sort: MatSort;
91+
@ViewChild(MatSort, {static: true}) sort!: MatSort;
9292
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class MatTableDataSource<
6969
* For example, a 'selectAll()' function would likely want to select the set of filtered data
7070
* shown to the user rather than all the data.
7171
*/
72-
filteredData: T[];
72+
filteredData!: T[];
7373

7474
/** Array of data that should be rendered by the table, where each object represents one row. */
7575
get data() {

src/material/table/table.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class MatTableApp {
698698
columnsToRender = ['column_a', 'column_b', 'column_c'];
699699
isFourthRow = (i: number, _rowData: TestData) => i == 3;
700700

701-
@ViewChild(MatTable) table: MatTable<TestData>;
701+
@ViewChild(MatTable) table!: MatTable<TestData>;
702702
}
703703

704704
@Component({
@@ -732,7 +732,7 @@ class NativeHtmlTableApp {
732732
dataSource = new FakeDataSource();
733733
columnsToRender = ['column_a', 'column_b', 'column_c'];
734734

735-
@ViewChild(MatTable) table: MatTable<TestData>;
735+
@ViewChild(MatTable) table!: MatTable<TestData>;
736736
}
737737

738738
@Component({
@@ -805,7 +805,7 @@ class StickyTableApp {
805805
dataSource = new FakeDataSource();
806806
columnsToRender = ['column_a'];
807807

808-
@ViewChild(MatTable) table: MatTable<TestData>;
808+
@ViewChild(MatTable) table!: MatTable<TestData>;
809809
}
810810

811811
@Component({
@@ -834,7 +834,7 @@ class MatTableWithWhenRowApp {
834834
dataSource = new FakeDataSource();
835835
isFourthRow = (i: number, _rowData: TestData) => i == 3;
836836

837-
@ViewChild(MatTable) table: MatTable<TestData>;
837+
@ViewChild(MatTable) table!: MatTable<TestData>;
838838
}
839839

840840
@Component({
@@ -872,10 +872,10 @@ class ArrayDataSourceMatTableApp implements AfterViewInit {
872872
dataSource = new MatTableDataSource<TestData>();
873873
columnsToRender = ['column_a', 'column_b', 'column_c'];
874874

875-
@ViewChild(MatTable) table: MatTable<TestData>;
876-
@ViewChild(MatPaginator) paginator: MatPaginator;
877-
@ViewChild(MatSort) sort: MatSort;
878-
@ViewChild(MatSortHeader) sortHeader: MatSortHeader;
875+
@ViewChild(MatTable) table!: MatTable<TestData>;
876+
@ViewChild(MatPaginator) paginator!: MatPaginator;
877+
@ViewChild(MatSort) sort!: MatSort;
878+
@ViewChild(MatSortHeader) sortHeader!: MatSortHeader;
879879

880880
constructor() {
881881
this.underlyingDataSource.data = [];
@@ -925,8 +925,8 @@ class MatTableWithSortApp implements OnInit {
925925
dataSource = new MatTableDataSource<TestData>();
926926
columnsToRender = ['column_a', 'column_b', 'column_c'];
927927

928-
@ViewChild(MatTable) table: MatTable<TestData>;
929-
@ViewChild(MatSort) sort: MatSort;
928+
@ViewChild(MatTable) table!: MatTable<TestData>;
929+
@ViewChild(MatSort) sort!: MatSort;
930930

931931
constructor() {
932932
this.underlyingDataSource.data = [];
@@ -977,8 +977,8 @@ class MatTableWithPaginatorApp implements OnInit {
977977
dataSource = new MatTableDataSource<TestData>();
978978
columnsToRender = ['column_a', 'column_b', 'column_c'];
979979

980-
@ViewChild(MatTable) table: MatTable<TestData>;
981-
@ViewChild(MatPaginator) paginator: MatPaginator;
980+
@ViewChild(MatTable) table!: MatTable<TestData>;
981+
@ViewChild(MatPaginator) paginator!: MatPaginator;
982982

983983
constructor() {
984984
this.underlyingDataSource.data = [];
@@ -1055,7 +1055,7 @@ class TableWithNgContainerRow {
10551055
class MatFlexTableApp {
10561056
dataSource = new FakeDataSource();
10571057
columnsToRender = ['column_a', 'column_b', 'column_c'];
1058-
@ViewChild(MatTable) table: MatTable<TestData>;
1058+
@ViewChild(MatTable) table!: MatTable<TestData>;
10591059
}
10601060

10611061
function getElements(element: Element, query: string): Element[] {

0 commit comments

Comments
 (0)