From 931c10b2e8a44e538a32e34691740ae33f558529 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Thu, 28 Jan 2021 13:21:12 +0100 Subject: [PATCH 1/2] More forgiving SvelteComponentDev typings Add `$$events_def` and `$$slot_def` so that users can do ``` let el: SvelteComponent; ``` Without type errors. Without this change, TS complains that `$$events_def` and `$$slot_def` is missing from `SvelteComponentDev` and therefore cannot be assigned to it. --- src/runtime/internal/dev.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index 53f6ef3bf1ba..99ff067474dd 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -115,6 +115,20 @@ export class SvelteComponentDev extends SvelteComponent { * ### DO NOT USE! */ $$prop_def: Props; + /** + * @private + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$events_def: any; + /** + * @private + * For type checking capabilities only. + * Does not exist at runtime. + * ### DO NOT USE! + */ + $$slot_def: any; constructor(options: { target: Element; From b8014e7ac812219b472db7252075ef66f8222a74 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 29 Jan 2021 10:53:40 -0500 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 176ef0a1c2c8..fffeb964beda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Throw a parser error for `class:` directives with an empty class name ([#5858](https://github.com/sveltejs/svelte/issues/5858)) * Fix type inference for derived stores ([#5935](https://github.com/sveltejs/svelte/pull/5935)) * Make parameters of built-in animations and transitions optional ([#5936](https://github.com/sveltejs/svelte/pull/5936)) +* Make `SvelteComponentDev` typings more forgiving ([#5937](https://github.com/sveltejs/svelte/pull/5937)) ## 3.32.0