diff --git a/src/model/data-consumer.ts b/src/model/data-consumer.ts index f189ebcc82..6be04e783e 100644 --- a/src/model/data-consumer.ts +++ b/src/model/data-consumer.ts @@ -184,10 +184,19 @@ export function isWhitespaceData(data: SeriesDataItemTypeM export function isFulfilledData[SeriesType]>( data: T ): data is Extract | LineData | HistogramData> { - return ( - (data as Partial>).open !== undefined || - (data as Partial>).value !== undefined - ); + return isFulfilledBarData(data) || isFulfilledLineData(data); +} + +export function isFulfilledBarData[SeriesType]>( + data: T +): data is Extract> { + return (data as Partial>).open !== undefined; +} + +export function isFulfilledLineData[SeriesType]>( + data: T +): data is Extract | HistogramData> { + return (data as Partial>).value !== undefined; } /** diff --git a/src/model/data-validators.ts b/src/model/data-validators.ts index 795c740c44..748a685940 100644 --- a/src/model/data-validators.ts +++ b/src/model/data-validators.ts @@ -2,7 +2,7 @@ import { assert } from '../helpers/assertions'; -import { isFulfilledData, SeriesDataItemTypeMap } from './data-consumer'; +import { isFulfilledBarData, isFulfilledLineData, SeriesDataItemTypeMap } from './data-consumer'; import { IHorzScaleBehavior } from './ihorz-scale-behavior'; import { CreatePriceLineOptions } from './price-line-options'; import { SeriesMarker } from './series-markers'; @@ -66,7 +66,7 @@ function checkBarItem( type: 'Bar' | 'Candlestick', barItem: SeriesDataItemTypeMap[typeof type] ): void { - if (!isFulfilledData(barItem)) { + if (!isFulfilledBarData(barItem)) { return; } @@ -104,7 +104,7 @@ function checkLineItem( type: 'Area' | 'Baseline' | 'Line' | 'Histogram', lineItem: SeriesDataItemTypeMap[typeof type] ): void { - if (!isFulfilledData(lineItem)) { + if (!isFulfilledLineData(lineItem)) { return; }