From 47735b72f245798fd5de462065dff4d4d615cb1e Mon Sep 17 00:00:00 2001 From: Marco polo Date: Fri, 18 Aug 2023 10:40:51 -0400 Subject: [PATCH] Update next-image types and fix image imports (#15921) Images are now imported as objects with a src attribute. Test Plan yarn ts --- .../packages/app-oss/custom-next-env.d.ts | 49 +++++++++++++ .../packages/app-oss/src/pages/_document.tsx | 2 + .../packages/app-oss/src/react-app-env.d.ts | 72 ------------------- .../packages/app-oss/src/typings.d.ts | 13 ++-- .../dagster-ui/packages/app-oss/tsconfig.json | 4 +- .../ui-components/custom-next-env.d.ts | 49 +++++++++++++ .../ui-components/src/components/Icon.tsx | 19 +---- .../packages/ui-components/src/types/svg.d.ts | 5 -- .../packages/ui-components/tsconfig.json | 2 +- .../packages/ui-core/src/graph/OpTags.tsx | 12 ++-- .../dagster-ui/packages/ui-core/typings.d.ts | 65 +++++++++++++---- 11 files changed, 164 insertions(+), 128 deletions(-) create mode 100644 js_modules/dagster-ui/packages/app-oss/custom-next-env.d.ts delete mode 100644 js_modules/dagster-ui/packages/app-oss/src/react-app-env.d.ts create mode 100644 js_modules/dagster-ui/packages/ui-components/custom-next-env.d.ts delete mode 100644 js_modules/dagster-ui/packages/ui-components/src/types/svg.d.ts diff --git a/js_modules/dagster-ui/packages/app-oss/custom-next-env.d.ts b/js_modules/dagster-ui/packages/app-oss/custom-next-env.d.ts new file mode 100644 index 0000000000000..03ccc583d0c44 --- /dev/null +++ b/js_modules/dagster-ui/packages/app-oss/custom-next-env.d.ts @@ -0,0 +1,49 @@ +/* eslint-disable import/no-default-export */ +/// + +type StaticImageData = { + src: string; + height: number; + width: number; + placeholder?: string; +}; + +declare module '*.svg' { + const content: StaticImageData; + export default content; +} + +declare module '*.jpg' { + const content: StaticImageData; + export default content; +} + +declare module '*.jpeg' { + const content: StaticImageData; + export default content; +} + +declare module '*.gif' { + const content: StaticImageData; + export default content; +} + +declare module '*.webp' { + const content: StaticImageData; + export default content; +} + +declare module '*.ico' { + const content: StaticImageData; + export default content; +} + +declare module '*.bmp' { + const content: StaticImageData; + export default content; +} + +declare module '*.avif' { + const content: StaticImageData; + export default content; +} diff --git a/js_modules/dagster-ui/packages/app-oss/src/pages/_document.tsx b/js_modules/dagster-ui/packages/app-oss/src/pages/_document.tsx index e8ec79b09d44a..d2c201eebccb1 100644 --- a/js_modules/dagster-ui/packages/app-oss/src/pages/_document.tsx +++ b/js_modules/dagster-ui/packages/app-oss/src/pages/_document.tsx @@ -17,12 +17,14 @@ export default function Document() { {/* Not sure if we need the following script */}