Skip to content

Commit

Permalink
Don't import internally from types in next-env.d.ts (#34394)
Browse files Browse the repository at this point in the history
* Move type to image component

* Add types/global.d.ts to excludes too

* Undo global exclude as it's using internally

* Don't add root imports for module augmentations
  • Loading branch information
lfades committed Feb 19, 2022
1 parent 4613e3b commit 27affb4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
7 changes: 7 additions & 0 deletions packages/next/client/image.tsx
Expand Up @@ -72,6 +72,13 @@ type OnLoadingComplete = (result: {

type ImgElementStyle = NonNullable<JSX.IntrinsicElements['img']['style']>

export interface StaticImageData {
src: string
height: number
width: number
blurDataURL?: string
}

interface StaticRequire {
default: StaticImageData
}
Expand Down
23 changes: 8 additions & 15 deletions packages/next/image-types/global.d.ts
@@ -1,15 +1,8 @@
// 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
}

declare module '*.png' {
const content: StaticImageData
const content: import('../dist/client/image').StaticImageData

export default content
}
Expand All @@ -26,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
}
2 changes: 1 addition & 1 deletion packages/next/tsconfig.json
Expand Up @@ -7,5 +7,5 @@
"moduleResolution": "node",
"jsx": "react"
},
"exclude": ["dist", "./*.d.ts"]
"exclude": ["dist", "./*.d.ts", "image-types/global.d.ts"]
}

0 comments on commit 27affb4

Please sign in to comment.