From 18d5388de032dce35839e2790c5f938237be996f Mon Sep 17 00:00:00 2001 From: Sloan Sparger <sloansparger@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:04:10 -0500 Subject: [PATCH] Upgrade to TypeScript v5.4 (#43736) --- .storybook/main.js | 3 ++ .../withPublicComponentWrapper.tsx | 2 +- .../hooks/private/use-init-data.ts | 2 +- frontend/src/metabase-lib/filter.ts | 10 +++++-- .../people/containers/AdminPeopleApp.tsx | 3 +- .../core/components/TabRow/TabRow.tsx | 1 - .../MainNavbar/SidebarItems/SidebarLink.tsx | 6 ++-- package.json | 3 +- tsconfig.base.json | 1 + yarn.lock | 28 +++++++++++++++---- 10 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.storybook/main.js b/.storybook/main.js index f6442bd0a11..2cab2a58d93 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -16,6 +16,9 @@ module.exports = { "@storybook/addon-a11y", ], babel: () => {}, + typescript: { + reactDocgen: "react-docgen-typescript-plugin", + }, webpackFinal: storybookConfig => ({ ...storybookConfig, plugins: [ diff --git a/enterprise/frontend/src/embedding-sdk/components/private/PublicComponentWrapper/withPublicComponentWrapper.tsx b/enterprise/frontend/src/embedding-sdk/components/private/PublicComponentWrapper/withPublicComponentWrapper.tsx index 2ef1df7e584..f0652db49ea 100644 --- a/enterprise/frontend/src/embedding-sdk/components/private/PublicComponentWrapper/withPublicComponentWrapper.tsx +++ b/enterprise/frontend/src/embedding-sdk/components/private/PublicComponentWrapper/withPublicComponentWrapper.tsx @@ -2,7 +2,7 @@ import type { ComponentType } from "react"; import { PublicComponentWrapper } from "./PublicComponentWrapper"; -export function withPublicComponentWrapper<P>( +export function withPublicComponentWrapper<P extends object>( WrappedComponent: ComponentType<P>, ): React.FC<P> { const WithPublicComponentWrapper: React.FC<P> = props => { diff --git a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data.ts b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data.ts index f9279d14663..0aeceee9011 100644 --- a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data.ts +++ b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data.ts @@ -73,7 +73,7 @@ export const useInitData = ({ config }: InitDataLoaderParameters) => { try { const [userResponse, siteSettingsResponse] = await Promise.all([ dispatch(refreshCurrentUser()), - dispatch(refreshSiteSettings()), + dispatch(refreshSiteSettings({})), ]); if ( diff --git a/frontend/src/metabase-lib/filter.ts b/frontend/src/metabase-lib/filter.ts index b2d958181ce..e08c392ec78 100644 --- a/frontend/src/metabase-lib/filter.ts +++ b/frontend/src/metabase-lib/filter.ts @@ -379,8 +379,14 @@ export function relativeDateFilterClause({ columnWithoutBucket, expressionClause("interval", [-offsetValue, offsetBucket]), ]), - expressionClause("relative-datetime", [value < 0 ? value : 0, bucket]), - expressionClause("relative-datetime", [value > 0 ? value : 0, bucket]), + expressionClause("relative-datetime", [ + value !== "current" && value < 0 ? value : 0, + bucket, + ]), + expressionClause("relative-datetime", [ + value !== "current" && value > 0 ? value : 0, + bucket, + ]), ]); } diff --git a/frontend/src/metabase/admin/people/containers/AdminPeopleApp.tsx b/frontend/src/metabase/admin/people/containers/AdminPeopleApp.tsx index e3f088ff4a7..2a747009b32 100644 --- a/frontend/src/metabase/admin/people/containers/AdminPeopleApp.tsx +++ b/frontend/src/metabase/admin/people/containers/AdminPeopleApp.tsx @@ -10,7 +10,8 @@ import { useSelector } from "metabase/lib/redux"; import { LeftNavWrapper } from "./AdminPeopleApp.styled"; export const AdminPeopleApp = ({ children }: { children: React.ReactNode }) => { - const shouldNudge = useSelector(shouldNudgeToPro); + const shouldNudge = useSelector(shouldNudgeToPro) as boolean; + return ( <AdminLayout sidebar={ diff --git a/frontend/src/metabase/core/components/TabRow/TabRow.tsx b/frontend/src/metabase/core/components/TabRow/TabRow.tsx index 2d914032b12..6abd75c324a 100644 --- a/frontend/src/metabase/core/components/TabRow/TabRow.tsx +++ b/frontend/src/metabase/core/components/TabRow/TabRow.tsx @@ -64,7 +64,6 @@ function TabRowInner<T>({ return; } const left = width * (direction === "left" ? -1 : 1); - // @ts-expect-error — https://github.com/Microsoft/TypeScript/issues/28755 tabListRef.current.scrollBy?.({ left, behavior: "instant" }); }, [width], diff --git a/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarLink.tsx b/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarLink.tsx index 34b4afc6d4d..c0dafc9bcd1 100644 --- a/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarLink.tsx +++ b/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarLink.tsx @@ -19,7 +19,7 @@ import { interface SidebarLinkProps { children: string; url?: string; - icon?: IconName | IconProps | React.ReactElement; + icon?: IconName | IconProps; isSelected?: boolean; hasDefaultIconStyle?: boolean; left?: React.ReactNode; @@ -31,9 +31,7 @@ type ContentProps = { children: React.ReactNode; }; -function isIconPropsObject( - icon: string | IconProps | React.ReactNode, -): icon is IconProps { +function isIconPropsObject(icon: string | IconProps): icon is IconProps { return _.isObject(icon); } diff --git a/package.json b/package.json index 171824829ba..9b6a5163aae 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "tether": "^1.2.0", "tippy.js": "^6.3.5", "ttag": "1.7.21", + "typescript": "^5.4.5", "underscore": "~1.13.3", "use-debounce": "^10.0.0", "yup": "^0.32.11" @@ -278,6 +279,7 @@ "prettier": "^2.7.1", "promise-loader": "^1.0.0", "raf": "^3.4.0", + "react-docgen-typescript-plugin": "^1.0.6", "react-refresh": "^0.13.0", "reg-cli": "^0.17.7", "shadow-cljs": "2.27.4", @@ -286,7 +288,6 @@ "stylelint-config-css-modules": "^4.4.0", "stylelint-config-standard": "^36.0.0", "terser-webpack-plugin": "^5.3.9", - "typescript": "^4.7.2", "webpack": "^5.85.0", "webpack-bundle-analyzer": "^4.10.1", "webpack-cli": "^5.1.1", diff --git a/tsconfig.base.json b/tsconfig.base.json index 978c05c8de4..cf666b6cc91 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -5,6 +5,7 @@ "allowSyntheticDefaultImports": true, "module": "commonjs", "isolatedModules": true, + "ignoreDeprecations": "5.0", "importsNotUsedAsValues": "error", "strict": true, "moduleResolution": "node", diff --git a/yarn.lock b/yarn.lock index 0c7bf78bde9..c7d6bf3752a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19323,7 +19323,20 @@ react-dnd@4: lodash "^4.17.10" shallowequal "^1.0.2" -react-docgen-typescript@^2.1.1: +react-docgen-typescript-plugin@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/react-docgen-typescript-plugin/-/react-docgen-typescript-plugin-1.0.6.tgz#bd036cd22ca437ddce253f212861e2253401a6f1" + integrity sha512-01ju9lihtH9G+q1jhyi2HEhNfPeQwmNe6zxrSQCGnL3fiBGUZve5Ll4voxIExMhsjEcmJtpmNr1J3FeBd+6PBw== + dependencies: + debug "^4.1.1" + endent "^2.0.1" + find-cache-dir "^3.3.1" + flat-cache "^3.0.4" + micromatch "^4.0.2" + react-docgen-typescript "^2.2.2" + tslib "^2.6.2" + +react-docgen-typescript@^2.1.1, react-docgen-typescript@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/react-docgen-typescript/-/react-docgen-typescript-2.2.2.tgz#4611055e569edc071204aadb20e1c93e1ab1659c" integrity sha512-tvg2ZtOpOi6QDwsb3GZhOjDkkX0h8Z2gipvTg6OVMUyoYoURhEiRNePT8NZItTVCDh39JJHnLdfCOkzoLbFnTg== @@ -22586,6 +22599,11 @@ tslib@^2.1.0, tslib@^2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslib@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -22758,10 +22776,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.7.2: - version "4.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.2.tgz#1f9aa2ceb9af87cca227813b4310fff0b51593c4" - integrity sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A== +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== uglify-js@^3.1.4: version "3.14.1" -- GitLab