Skip to content

Commit 6928aac

Browse files
authored
feat: enable TS autocomplete for Svelte HTML element definitions (#15972)
Covers #15971. adds autocomplete support to SvelteHTMLElements while preserving its functionality that key can be any string using string & {} TS trick.
1 parent 08346b5 commit 6928aac

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/svelte/elements.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ export interface SvelteHTMLElements {
20662066
failed?: import('svelte').Snippet<[error: unknown, reset: () => void]>;
20672067
};
20682068

2069-
[name: string]: { [name: string]: any };
2069+
[name: string & {}]: { [name: string]: any };
20702070
}
20712071

20722072
export type ClassValue = string | import('clsx').ClassArray | import('clsx').ClassDictionary;

packages/svelte/svelte-html.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as svelteElements from './elements.js';
88
/**
99
* @internal do not use
1010
*/
11-
type HTMLProps<Property extends string, Override> = Omit<
11+
type HTMLProps<Property extends keyof svelteElements.SvelteHTMLElements, Override> = Omit<
1212
import('./elements.js').SvelteHTMLElements[Property],
1313
keyof Override
1414
> &
@@ -250,7 +250,7 @@ declare global {
250250
};
251251
// don't type svelte:options, it would override the types in svelte/elements and it isn't extendable anyway
252252

253-
[name: string]: { [name: string]: any };
253+
[name: string & {}]: { [name: string]: any };
254254
}
255255
}
256256
}

0 commit comments

Comments
 (0)