Chore: Refactor QueryRunner to remove type assertions (#42329)

This commit is contained in:
Josh Hunt
2021-11-26 10:28:13 +00:00
committed by GitHub
parent d862d210e4
commit 62e55f4724

View File

@@ -70,7 +70,7 @@ export class QueryRunner implements QueryRunnerSrv {
}; };
// Add deprecated property // Add deprecated property
(request as any).rangeRaw = timeRange.raw; request.rangeRaw = timeRange.raw;
from(getDataSource(datasource, request.scopedVars)) from(getDataSource(datasource, request.scopedVars))
.pipe(first()) .pipe(first())
@@ -144,8 +144,9 @@ async function getDataSource(
datasource: DataSourceRef | DataSourceApi | null, datasource: DataSourceRef | DataSourceApi | null,
scopedVars: ScopedVars scopedVars: ScopedVars
): Promise<DataSourceApi> { ): Promise<DataSourceApi> {
if (datasource && (datasource as any).query) { if (datasource && 'query' in datasource) {
return datasource as DataSourceApi; return datasource;
} }
return await getDatasourceSrv().get(datasource, scopedVars);
return getDatasourceSrv().get(datasource, scopedVars);
} }