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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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