Skip to content

Commit cf99ac8

Browse files
fix: use correct type for '*?enhanced' imports (#12224)
1 parent b0116ff commit cf99ac8

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.changeset/cool-grapes-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/enhanced-img': patch
3+
---
4+
5+
fix: use correct type for `*?enhanced` imports
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import type { Picture } from 'vite-imagetools';
2+
13
declare module '*?enhanced' {
2-
const value: string;
4+
const value: Picture;
35
export default value;
46
}

packages/enhanced-img/types/index.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import type { HTMLImgAttributes } from 'svelte/elements';
12
import type { Plugin } from 'vite';
3+
import type { Picture } from 'vite-imagetools';
24
import './ambient.js';
3-
import { HTMLImgAttributes } from 'svelte/elements';
5+
6+
type EnhancedImgAttributes = Omit<HTMLImgAttributes, 'src'> & { src: string | Picture };
47

58
// https://svelte.dev/docs/typescript#enhancing-built-in-dom-types
69
declare module 'svelte/elements' {
710
export interface SvelteHTMLElements {
8-
'enhanced:img': HTMLImgAttributes;
11+
'enhanced:img': EnhancedImgAttributes;
912
}
1013
}
1114

0 commit comments

Comments
 (0)