From 88fe2544717a19ce36306ca22dc0c78bf5692c48 Mon Sep 17 00:00:00 2001 From: LFades Date: Tue, 15 Feb 2022 18:50:27 -0500 Subject: [PATCH 1/4] Move type to image component --- packages/next/client/image.tsx | 7 +++++++ packages/next/image-types/global.d.ts | 7 +------ packages/next/tsconfig.json | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index a634db7a22dd..a0632eda2354 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -61,6 +61,13 @@ type OnLoadingComplete = (result: { type ImgElementStyle = NonNullable +export interface StaticImageData { + src: string + height: number + width: number + blurDataURL?: string +} + interface StaticRequire { default: StaticImageData } diff --git a/packages/next/image-types/global.d.ts b/packages/next/image-types/global.d.ts index 1a1c9642b8b3..13ca432fd91c 100644 --- a/packages/next/image-types/global.d.ts +++ b/packages/next/image-types/global.d.ts @@ -1,12 +1,7 @@ // this file is conditionally added/removed to next-env.d.ts // if the static image import handling is enabled -interface StaticImageData { - src: string - height: number - width: number - blurDataURL?: string -} +import type { StaticImageData } from '../dist/client/image' declare module '*.png' { const content: StaticImageData diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index ddcf7c62d2f9..05eb6a32cc15 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -7,5 +7,5 @@ "moduleResolution": "node", "jsx": "react" }, - "exclude": ["dist", "./*.d.ts"] + "exclude": ["dist", "./*.d.ts", "image-types/global.d.ts"] } From 2ea946956de52adcd2be6b4ca528aed4fd2b4d4e Mon Sep 17 00:00:00 2001 From: LFades Date: Tue, 15 Feb 2022 20:18:15 -0500 Subject: [PATCH 2/4] Add types/global.d.ts to excludes too --- packages/next/tsconfig.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index 05eb6a32cc15..b7b6e90cef76 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -7,5 +7,10 @@ "moduleResolution": "node", "jsx": "react" }, - "exclude": ["dist", "./*.d.ts", "image-types/global.d.ts"] + "exclude": [ + "dist", + "./*.d.ts", + "image-types/global.d.ts", + "types/global.d.ts" + ] } From a6067defc0ff585daf1163934199649b07cf9428 Mon Sep 17 00:00:00 2001 From: LFades Date: Tue, 15 Feb 2022 20:23:28 -0500 Subject: [PATCH 3/4] Undo global exclude as it's using internally --- packages/next/tsconfig.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/next/tsconfig.json b/packages/next/tsconfig.json index b7b6e90cef76..05eb6a32cc15 100644 --- a/packages/next/tsconfig.json +++ b/packages/next/tsconfig.json @@ -7,10 +7,5 @@ "moduleResolution": "node", "jsx": "react" }, - "exclude": [ - "dist", - "./*.d.ts", - "image-types/global.d.ts", - "types/global.d.ts" - ] + "exclude": ["dist", "./*.d.ts", "image-types/global.d.ts"] } From 3f68785398c9a1e878424add609c2b05a08ae6a9 Mon Sep 17 00:00:00 2001 From: LFades Date: Wed, 16 Feb 2022 11:26:27 -0500 Subject: [PATCH 4/4] Don't add root imports for module augmentations --- packages/next/image-types/global.d.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/next/image-types/global.d.ts b/packages/next/image-types/global.d.ts index 13ca432fd91c..4c5a72d84bb7 100644 --- a/packages/next/image-types/global.d.ts +++ b/packages/next/image-types/global.d.ts @@ -1,10 +1,8 @@ // this file is conditionally added/removed to next-env.d.ts // if the static image import handling is enabled -import type { StaticImageData } from '../dist/client/image' - declare module '*.png' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } @@ -21,43 +19,43 @@ declare module '*.svg' { } declare module '*.jpg' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.jpeg' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.gif' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.webp' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.avif' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.ico' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content } declare module '*.bmp' { - const content: StaticImageData + const content: import('../dist/client/image').StaticImageData export default content }