Skip to content

Commit

Permalink
Changing type guard
Browse files Browse the repository at this point in the history
  • Loading branch information
simianhacker committed Aug 31, 2021
1 parent c325be1 commit 26e31f1
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { mapValues, first, last, isNaN, isNumber } from 'lodash';
import { mapValues, first, last, isNaN, isNumber, isObject, has } from 'lodash';
import moment from 'moment';
import { ElasticsearchClient } from 'kibana/server';
import {
Expand Down Expand Up @@ -41,8 +41,10 @@ interface AggregationWithIntervals {

type Aggregation = AggregationWithIntervals | AggregationWithoutIntervals;

function isAggregationWithIntervals(subject: any): subject is AggregationWithIntervals {
return Boolean(subject.aggregatedIntervals);
function isAggregationWithIntervals(
subject: Aggregation | undefined
): subject is AggregationWithIntervals {
return isObject(subject) && has(subject, 'aggregatedIntervals');
}

interface CompositeAggregationsResponse {
Expand Down

0 comments on commit 26e31f1

Please sign in to comment.