From d93ad3ba1e8c28c2facaec49e19d2ac1ed577e9f Mon Sep 17 00:00:00 2001 From: FoHoOV <53280503+FoHoOV@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:55:49 +0330 Subject: [PATCH] feat: add `ComponentExports` utility type (#13441) Safer/clearer/backwards/forward-compatibale way to reference them --------- Co-authored-by: Simon Holthausen --- .changeset/rotten-cups-float.md | 5 +++++ packages/svelte/src/index.d.ts | 20 ++++++++++++++++++ packages/svelte/tests/types/component.ts | 26 +++++++++++++++++++++++- packages/svelte/types/index.d.ts | 20 ++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .changeset/rotten-cups-float.md diff --git a/.changeset/rotten-cups-float.md b/.changeset/rotten-cups-float.md new file mode 100644 index 000000000000..e58d4f26dfe1 --- /dev/null +++ b/.changeset/rotten-cups-float.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: provide `ComponentExports` utility type diff --git a/packages/svelte/src/index.d.ts b/packages/svelte/src/index.d.ts index 5130721cbed2..262337ef0aaf 100644 --- a/packages/svelte/src/index.d.ts +++ b/packages/svelte/src/index.d.ts @@ -237,6 +237,26 @@ export type ComponentProps> = ? Props : never; +/** + * Convenience type to get the properties that given component exports. + * + * Example: Typing the `bind:this` for a component named `MyComponent` + * ``` + *