feat(fe): upgrade superset-frontend to Typescript v5 (#31979)

Signed-off-by: hainenber <dotronghai96@gmail.com>
Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
Đỗ Trọng Hải
2025-01-29 18:40:33 +07:00
committed by GitHub
parent a21f184058
commit 19e8a7049b
141 changed files with 1095 additions and 572 deletions

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import { fireEvent, render } from 'spec/helpers/testing-library';
import KeyboardShortcutButton, { KEY_MAP } from '.';
import KeyboardShortcutButton, { KEY_MAP, KeyboardShortcut } from '.';
test('renders shortcut description', () => {
const { getByText, getByRole } = render(
@@ -26,7 +26,7 @@ test('renders shortcut description', () => {
fireEvent.click(getByRole('button'));
expect(getByText('Keyboard shortcuts')).toBeInTheDocument();
Object.keys(KEY_MAP)
.filter(key => Boolean(KEY_MAP[key]))
.filter(key => Boolean(KEY_MAP[key as KeyboardShortcut]))
.forEach(key => {
expect(getByText(key)).toBeInTheDocument();
});

View File

@@ -42,7 +42,7 @@ export enum KeyboardShortcut {
CtrlRight = 'ctrl+]',
}
export const KEY_MAP = {
export const KEY_MAP: Record<KeyboardShortcut, string | undefined> = {
[KeyboardShortcut.CtrlR]: t('Run query'),
[KeyboardShortcut.CtrlEnter]: t('Run query'),
[KeyboardShortcut.AltEnter]: t('Run query'),
@@ -62,15 +62,14 @@ export const KEY_MAP = {
[KeyboardShortcut.CtrlH]: userOS !== 'MacOS' ? t('Replace') : undefined,
};
const KeyMapByCommand = Object.entries(KEY_MAP).reduce(
(acc, [shortcut, command]) => {
if (command) {
acc[command] = [...(acc[command] || []), shortcut];
}
return acc;
},
{} as Record<string, string[]>,
);
const KeyMapByCommand = Object.entries(KEY_MAP).reduce<
Record<string, string[]>
>((acc, [shortcut, command]) => {
if (command) {
acc[command] = [...(acc[command] || []), shortcut];
}
return acc;
}, {});
const ShortcutDescription = styled.span`
font-size: ${({ theme }) => theme.typography.sizes.m}px;

View File

@@ -103,7 +103,9 @@ const QueryTable = ({
columns.map(column => ({
accessor: column,
Header:
QUERY_HISTORY_TABLE_HEADERS_LOCALIZED[column] || setHeaders(column),
QUERY_HISTORY_TABLE_HEADERS_LOCALIZED[
column as keyof typeof QUERY_HISTORY_TABLE_HEADERS_LOCALIZED
] || setHeaders(column),
disableSortBy: true,
})),
[columns],
@@ -221,6 +223,17 @@ const QueryTable = ({
label: t('Unknown Status'),
},
},
started: {
config: {
icon: (
<Icons.LoadingOutlined
iconColor={theme.colors.primary.base}
iconSize="m"
/>
),
label: t('Started'),
},
},
};
return queries

View File

@@ -68,10 +68,10 @@ const getValidator = () => {
const rules: any = getValidationRules();
return (formData: Record<string, any>, errors: FormValidation) => {
rules.forEach((rule: any) => {
const test = validators[rule.name];
const test = validators[rule.name as keyof typeof validators];
const args = rule.arguments.map((name: string) => formData[name]);
const container = rule.container || rule.arguments.slice(-1)[0];
if (!test(...args)) {
if (!test(args[0], args[1])) {
errors[container]?.addError(rule.message);
}
});