diff --git a/superset-frontend/packages/superset-ui-core/src/query/getXAxis.ts b/superset-frontend/packages/superset-ui-core/src/query/getXAxis.ts index 78c896f23409c..7c329c2a8bdff 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/getXAxis.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/getXAxis.ts @@ -24,6 +24,7 @@ import { isQueryFormColumn, QueryFormData, QueryFormColumn, + Optional, } from '@superset-ui/core'; export const isXAxisSet = (formData: QueryFormData) => @@ -35,7 +36,7 @@ export const hasGenericChartAxes = isFeatureEnabled( export const getXAxisColumn = ( formData: QueryFormData, -): QueryFormColumn | undefined => { +): Optional => { // The formData should be "raw form_data" -- the snake_case version of formData rather than camelCase. if (!(formData.granularity_sqla || formData.x_axis)) { return undefined; @@ -47,7 +48,7 @@ export const getXAxisColumn = ( return DTTM_ALIAS; }; -export const getXAxisLabel = (formData: QueryFormData): string | undefined => { +export const getXAxisLabel = (formData: QueryFormData): Optional => { const col = getXAxisColumn(formData); if (col) { return getColumnLabel(col); diff --git a/superset-frontend/packages/superset-ui-core/src/types/index.ts b/superset-frontend/packages/superset-ui-core/src/types/index.ts index 7c75ad42cc8c2..a1c527afd6f06 100644 --- a/superset-frontend/packages/superset-ui-core/src/types/index.ts +++ b/superset-frontend/packages/superset-ui-core/src/types/index.ts @@ -20,4 +20,6 @@ export * from '../query/types'; export type Maybe = T | null; +export type Optional = T | undefined; + export type ValueOf = T[keyof T];