diff --git a/src/cdk/table/table.ts b/src/cdk/table/table.ts index 4ce0f934551..b5f2aa7019b 100644 --- a/src/cdk/table/table.ts +++ b/src/cdk/table/table.ts @@ -64,6 +64,13 @@ export interface RowOutlet { viewContainer: ViewContainerRef; } +/** + * Union of the types that can be set as the data source for a `CdkTable`. + * @docs-private + */ +type CdkTableDataSourceInput = DataSource | Observable | T[]> | + ReadonlyArray | T[]; + /** * Provides a handle for the table to grab the view container's ng-container to insert data rows. * @docs-private @@ -310,13 +317,13 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes * subscriptions registered during the connect process). */ @Input() - get dataSource(): DataSource | Observable | T[] { return this._dataSource; } - set dataSource(dataSource: DataSource | Observable | T[]) { + get dataSource(): CdkTableDataSourceInput { return this._dataSource; } + set dataSource(dataSource: CdkTableDataSourceInput) { if (this._dataSource !== dataSource) { this._switchDataSource(dataSource); } } - private _dataSource: DataSource | Observable | T[] | T[]; + private _dataSource: CdkTableDataSourceInput; /** * Whether to allow multiple rows per data object by evaluating which rows evaluate their 'when' @@ -759,7 +766,7 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes * render change subscription if one exists. If the data source is null, interpret this by * clearing the row outlet. Otherwise start listening for new data. */ - private _switchDataSource(dataSource: DataSource | Observable | T[]) { + private _switchDataSource(dataSource: CdkTableDataSourceInput) { this._data = []; if (this.dataSource instanceof DataSource) {