Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

chore: upgrade typescript to 5.9 (#61494)

Uladzimir Havenchyk9668ebe98c56
diff --git a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/SmartLink/SmartLinkNode.tsx b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/SmartLink/SmartLinkNode.tsx
index f7a12151231..88ac6b3bd3d 100644
--- a/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/SmartLink/SmartLinkNode.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/rich_text_editing/tiptap/extensions/SmartLink/SmartLinkNode.tsx
@@ -190,7 +190,7 @@ export const SmartLink = Node.create<{
"data-model": model,
"data-label": label ?? undefined,
"data-site-url": this.options.siteUrl,
- href: this.options.siteUrl + href ?? "",
+ href: this.options.siteUrl + href,
style: "text-decoration: none;",
},
this.options.HTMLAttributes,
diff --git a/frontend/src/metabase/admin/performance/components/StrategyForm.styled.tsx b/frontend/src/metabase/admin/performance/components/StrategyForm.styled.tsx
index ce35d71b9e5..b46cf408d85 100644
--- a/frontend/src/metabase/admin/performance/components/StrategyForm.styled.tsx
+++ b/frontend/src/metabase/admin/performance/components/StrategyForm.styled.tsx
@@ -1,7 +1,6 @@
// eslint-disable-next-line no-restricted-imports
import styled from "@emotion/styled";
-import { Form } from "metabase/forms";
import { FixedSizeIcon, Group, Loader } from "metabase/ui";
export const LoaderInButton = styled(Loader)`
@@ -20,12 +19,6 @@ export const FormWrapper = styled.div`
flex-direction: column;
`;
-export const StyledForm = styled(Form)`
- display: flex;
- flex-direction: column;
- flex-grow: 1;
-`;
-
export const StyledFormButtonsGroup = styled(Group)<{ isInSidebar?: boolean }>`
padding-block: 1rem;
gap: 1rem;
diff --git a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx b/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
index b1294763ad0..54841b76402 100644
--- a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
+++ b/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
@@ -9,6 +9,7 @@ import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErr
import { Schedule } from "metabase/common/components/Schedule/Schedule";
import type { FormTextInputProps } from "metabase/forms";
import {
+ Form,
FormProvider,
FormRadioGroup,
FormSubmitButton,
@@ -53,7 +54,6 @@ import Styles from "./PerformanceApp.module.css";
import {
FormWrapper,
LoaderInButton,
- StyledForm,
StyledFormButtonsGroup,
} from "./StrategyForm.styled";
@@ -218,8 +218,13 @@ const StrategyFormBody = ({
return (
<FormWrapper>
- <StyledForm
- style={{ overflow: isInSidebar ? undefined : "auto" }}
+ <Form
+ display="flex"
+ style={{
+ overflow: isInSidebar ? undefined : "auto",
+ flexDirection: "column",
+ flexGrow: 1,
+ }}
aria-labelledby={headingId}
data-testid={`strategy-form-for-${targetModel}-${targetId}`}
>
@@ -306,7 +311,7 @@ const StrategyFormBody = ({
isInSidebar={isInSidebar}
dirty={dirty}
/>
- </StyledForm>
+ </Form>
</FormWrapper>
);
};
diff --git a/frontend/src/metabase/lib/colors/groups.ts b/frontend/src/metabase/lib/colors/groups.ts
index 10aa9ce310f..28a7e13f73d 100644
--- a/frontend/src/metabase/lib/colors/groups.ts
+++ b/frontend/src/metabase/lib/colors/groups.ts
@@ -13,7 +13,7 @@ export const getAccentColors = (
}: AccentColorOptions = {},
palette?: ColorPalette,
): ColorName[] => {
- const ranges = [];
+ const ranges: ColorName[][] = [];
main && ranges.push(getMainAccentColors(palette, gray));
light && ranges.push(getLightAccentColors(palette, gray));
dark && ranges.push(getDarkAccentColors(palette, gray));
@@ -22,7 +22,10 @@ export const getAccentColors = (
};
const getBaseAccentsNames = (withGray = false) => {
- const accents = _.times(ACCENT_COUNT, (i) => `accent${i}`);
+ const accents: ColorName[] = _.times(
+ ACCENT_COUNT,
+ (i) => `accent${i}` as ColorName,
+ );
if (withGray) {
accents.push("accent-gray");
}
@@ -33,16 +36,16 @@ const getBaseAccentsNames = (withGray = false) => {
export const getMainAccentColors = (
palette?: ColorPalette,
withGray = false,
-) => {
+): ColorName[] => {
return getBaseAccentsNames(withGray).map((accent) => color(accent, palette));
};
export const getLightAccentColors = (
palette?: ColorPalette,
withGray = false,
-) => {
+): ColorName[] => {
return getBaseAccentsNames(withGray).map((accent) =>
- color(`${accent}-light`, palette),
+ color(`${accent}-light` as ColorName, palette),
);
};
@@ -51,7 +54,7 @@ export const getDarkAccentColors = (
withGray = false,
) => {
return getBaseAccentsNames(withGray).map((accent) =>
- color(`${accent}-dark`, palette),
+ color(`${accent}-dark` as ColorName, palette),
);
};
diff --git a/frontend/src/metabase/lib/colors/palette.ts b/frontend/src/metabase/lib/colors/palette.ts
index 902cb1d5a74..5c34628ef83 100644
--- a/frontend/src/metabase/lib/colors/palette.ts
+++ b/frontend/src/metabase/lib/colors/palette.ts
@@ -3,7 +3,7 @@ import Color from "color";
import type { ColorGetter } from "metabase/visualizations/types";
import { colors } from "./colors";
-import type { ColorPalette } from "./types";
+import type { ColorName, ColorPalette } from "./types";
export const ACCENT_COUNT = 8;
@@ -51,10 +51,7 @@ export const aliases: Record<string, (palette: ColorPalette) => string> = {
* When the hex values are needed, use the themeColor function
* from Mantine's theme, i.e. `theme.fn.themeColor("text-light")`
*/
-export function color(
- colorName: keyof ColorPalette,
- palette?: ColorPalette,
-): string;
+export function color(colorName: ColorName, palette?: ColorPalette): ColorName;
export function color(color: string, palette?: ColorPalette): string;
export function color(color: any, palette: ColorPalette = colors) {
const fullPalette = {
diff --git a/frontend/src/metabase/lib/formatting/numbers.tsx b/frontend/src/metabase/lib/formatting/numbers.tsx
index c96e7413712..2cc056bedb1 100644
--- a/frontend/src/metabase/lib/formatting/numbers.tsx
+++ b/frontend/src/metabase/lib/formatting/numbers.tsx
@@ -187,9 +187,10 @@ export function numberFormatterForOptions(options: FormatNumberOptions) {
// always use "en" locale so we have known number separators we can replace depending on number_separators option
// TODO: if we do that how can we get localized currency names?
return new Intl.NumberFormat("en", {
- style: options.number_style,
+ style: options.number_style as Intl.NumberFormatOptions["style"],
currency: options.currency,
- currencyDisplay: options.currency_style,
+ currencyDisplay:
+ options.currency_style as Intl.NumberFormatOptions["currencyDisplay"],
// always use grouping separators, but we may replace/remove them depending on number_separators option
useGrouping: true,
minimumIntegerDigits: options.minimumIntegerDigits,
diff --git a/frontend/src/metabase/services.js b/frontend/src/metabase/services.js
index 83859078ec7..446b68d7af4 100644
--- a/frontend/src/metabase/services.js
+++ b/frontend/src/metabase/services.js
@@ -80,6 +80,10 @@ export function maybeUsePivotEndpoint(api, card, metadata) {
return api;
}
+/**
+ * @param {*} question
+ * @param {object} param
+ */
export async function runQuestionQuery(
question,
{
diff --git a/frontend/src/metabase/setup/components/UserForm/UserForm.styled.tsx b/frontend/src/metabase/setup/components/UserForm/UserForm.styled.tsx
index f77aab3ad20..209fb7c6231 100644
--- a/frontend/src/metabase/setup/components/UserForm/UserForm.styled.tsx
+++ b/frontend/src/metabase/setup/components/UserForm/UserForm.styled.tsx
@@ -1,13 +1,8 @@
// eslint-disable-next-line no-restricted-imports
import styled from "@emotion/styled";
-import { Form } from "metabase/forms";
import { breakpointMinSmall } from "metabase/styled-components/theme";
-export const UserFormRoot = styled(Form)`
- margin-top: 1rem;
-`;
-
export const UserFieldGroup = styled.div`
${breakpointMinSmall} {
display: grid;
diff --git a/frontend/src/metabase/setup/components/UserForm/UserForm.tsx b/frontend/src/metabase/setup/components/UserForm/UserForm.tsx
index a6912e1d641..db0cba1baba 100644
--- a/frontend/src/metabase/setup/components/UserForm/UserForm.tsx
+++ b/frontend/src/metabase/setup/components/UserForm/UserForm.tsx
@@ -5,13 +5,13 @@ import * as Yup from "yup";
import FormInput from "metabase/common/components/FormInput";
import FormSubmitButton from "metabase/common/components/FormSubmitButton";
-import { FormProvider, useFormSubmitButton } from "metabase/forms";
+import { Form, FormProvider, useFormSubmitButton } from "metabase/forms";
import * as Errors from "metabase/lib/errors";
import { validatePassword } from "metabase/setup/utils";
import { Flex } from "metabase/ui";
import type { UserInfo } from "metabase-types/store";
-import { UserFieldGroup, UserFormRoot } from "./UserForm.styled";
+import { UserFieldGroup } from "./UserForm.styled";
const USER_SCHEMA = Yup.object({
first_name: Yup.string().nullable().default(null).max(100, Errors.maxLength),
@@ -54,7 +54,7 @@ export const UserForm = ({ user, isHosted, onSubmit }: UserFormProps) => {
validationContext={validationContext}
onSubmit={onSubmit}
>
- <UserFormRoot>
+ <Form mt="md">
<UserFieldGroup>
<FormInput
name="first_name"
@@ -98,7 +98,7 @@ export const UserForm = ({ user, isHosted, onSubmit }: UserFormProps) => {
placeholder={t`Shhh... but one more time so we get it right`}
/>
<UserFormSubmitButton />
- </UserFormRoot>
+ </Form>
</FormProvider>
);
};
diff --git a/frontend/src/metabase/visualizations/echarts/cartesian/option/axis.ts b/frontend/src/metabase/visualizations/echarts/cartesian/option/axis.ts
index 79bbf954ae2..ad18cf7c4b4 100644
--- a/frontend/src/metabase/visualizations/echarts/cartesian/option/axis.ts
+++ b/frontend/src/metabase/visualizations/echarts/cartesian/option/axis.ts
@@ -385,18 +385,24 @@ export const buildMetricAxis = (
const range = getYAxisRange(axisModel, yAxisScaleTransforms, settings);
+ const {
+ type: _omitType,
+ mainType: _omitMainType,
+ ...axisNameOptions
+ } = getAxisNameDefaultOption(
+ renderingContext,
+ nameGap,
+ axisModel.label,
+ shouldFlipAxisName ? -90 : undefined,
+ );
+
return {
show: true,
scale: !!settings["graph.y_axis.unpin_from_zero"],
type: "value",
splitNumber: axisModel.splitNumber,
...range,
- ...getAxisNameDefaultOption(
- renderingContext,
- nameGap,
- axisModel.label,
- shouldFlipAxisName ? -90 : undefined,
- ),
+ ...axisNameOptions,
splitLine: settings["graph.y_axis.axis_enabled"]
? {
lineStyle: {
@@ -417,7 +423,6 @@ export const buildMetricAxis = (
margin: CHART_STYLE.axisTicksMarginY,
show: !!settings["graph.y_axis.axis_enabled"],
...getTicksDefaultOption(renderingContext),
- // @ts-expect-error TODO: figure out EChart types
formatter: (rawValue) =>
axisModel.formatter(
yAxisScaleTransforms.fromEChartsAxisValue(rawValue),
diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.module.css b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.module.css
new file mode 100644
index 00000000000..18fe556962c
--- /dev/null
+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.module.css
@@ -0,0 +1,4 @@
+.isSelected {
+ color: var(--mb-color-brand);
+ background-color: var(--mb-color-brand-lighter);
+}
diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.styled.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.styled.tsx
index 002cbfbb2b1..ecb6235084b 100644
--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.styled.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SettingsComponents/MenuItem.styled.tsx
@@ -1,19 +1,20 @@
-// eslint-disable-next-line no-restricted-imports
-import { css } from "@emotion/react";
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-import type { HTMLAttributes } from "react";
+import cx from "classnames";
import type { MenuItemProps } from "metabase/ui";
import { Menu } from "metabase/ui";
-type MenuItemStyledProps = MenuItemProps & HTMLAttributes<HTMLButtonElement>;
+import S from "./MenuItem.module.css";
-export const MenuItemStyled = styled(Menu.Item)<MenuItemStyledProps>`
- ${({ "aria-selected": isSelected }) =>
- isSelected &&
- css`
- color: var(--mb-color-brand);
- background-color: var(--mb-color-brand-lighter);
- `}
-`;
+type MenuItemStyledProps = MenuItemProps &
+ React.HTMLAttributes<HTMLButtonElement>;
+
+export const MenuItemStyled = (props: MenuItemStyledProps) => {
+ const isSelected = props["aria-selected"];
+
+ return (
+ <Menu.Item
+ {...props}
+ className={cx(props.className, { [S.isSelected]: isSelected })}
+ />
+ );
+};
diff --git a/package.json b/package.json
index efe42deafd7..300c37edfc6 100644
--- a/package.json
+++ b/package.json
@@ -147,7 +147,7 @@
"tippy.js": "^6.3.7",
"ts-pattern": "^5.1.2",
"ttag": "1.7.21",
- "typescript": "^5.4.5",
+ "typescript": "^5.9.2",
"underscore": "~1.13.3",
"yup": "^0.32.11"
},
diff --git a/yarn.lock b/yarn.lock
index 46f43f6be92..3e1c7be8070 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -21044,12 +21044,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4"
integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==
-typescript@^5.3.3, typescript@^5.4.5:
- version "5.4.5"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
- integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==
-
-typescript@^5.7.3, typescript@^5.8.3:
+typescript@^5.3.3, typescript@^5.7.3, typescript@^5.8.3, typescript@^5.9.2:
version "5.9.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.2.tgz#d93450cddec5154a2d5cabe3b8102b83316fb2a6"
integrity sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==