refactor(explore): improve typing for Dnd controls (#16362)

This commit is contained in:
Jesse Yang
2021-08-26 01:23:14 -07:00
committed by GitHub
parent 18be181946
commit ec087507e5
17 changed files with 237 additions and 168 deletions

View File

@@ -22,25 +22,25 @@ import { ensureIsArray } from '@superset-ui/core';
export class OptionSelector {
values: ColumnMeta[];
options: { string: ColumnMeta };
options: Record<string, ColumnMeta>;
multi: boolean;
constructor(
options: { string: ColumnMeta },
options: Record<string, ColumnMeta>,
multi: boolean,
initialValues?: string[] | string,
initialValues?: string[] | string | null,
) {
this.options = options;
this.multi = multi;
this.values = ensureIsArray(initialValues)
.map(value => {
if (value in options) {
if (value && value in options) {
return options[value];
}
return null;
})
.filter(Boolean);
.filter(Boolean) as ColumnMeta[];
}
add(value: string) {