From 7e4c234d021406a490b71a6fe457fa7443a1567e Mon Sep 17 00:00:00 2001 From: Yongjie Zhao Date: Wed, 19 Oct 2022 10:06:46 +0800 Subject: [PATCH] add Optional type --- .../packages/superset-ui-core/src/query/getXAxis.ts | 5 +++-- .../packages/superset-ui-core/src/types/index.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) 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];