Skip to content

Commit

Permalink
add Optional type
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Oct 19, 2022
1 parent 2a8d8fa commit 7e4c234
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
isQueryFormColumn,
QueryFormData,
QueryFormColumn,
Optional,
} from '@superset-ui/core';

export const isXAxisSet = (formData: QueryFormData) =>
Expand All @@ -35,7 +36,7 @@ export const hasGenericChartAxes = isFeatureEnabled(

export const getXAxisColumn = (
formData: QueryFormData,
): QueryFormColumn | undefined => {
): Optional<QueryFormColumn> => {
// 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;
Expand All @@ -47,7 +48,7 @@ export const getXAxisColumn = (
return DTTM_ALIAS;
};

export const getXAxisLabel = (formData: QueryFormData): string | undefined => {
export const getXAxisLabel = (formData: QueryFormData): Optional<string> => {
const col = getXAxisColumn(formData);
if (col) {
return getColumnLabel(col);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ export * from '../query/types';

export type Maybe<T> = T | null;

export type Optional<T> = T | undefined;

export type ValueOf<T> = T[keyof T];

0 comments on commit 7e4c234

Please sign in to comment.