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;