From cd3e287b06164477c1abbdd846bc2defd998533d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 19 Jul 2024 09:02:14 -0400 Subject: [PATCH] expose internals --- packages/svelte/src/index.d.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/svelte/src/index.d.ts b/packages/svelte/src/index.d.ts index f56b4c66e0..bf5d5e419e 100644 --- a/packages/svelte/src/index.d.ts +++ b/packages/svelte/src/index.d.ts @@ -109,6 +109,11 @@ declare const brand: unique symbol; type Brand = { [brand]: B }; type Branded = T & Brand; +/** + * Internal implementation details that vary between environments + */ +export type ComponentInternals = Branded<{}, 'ComponentInternals'>; + /** * Can be used to create strongly typed Svelte components. * @@ -142,7 +147,7 @@ export interface Component< */ ( this: void, - internal: Branded<{}, 'ComponentInternals'>, + internals: ComponentInternals, props: Props ): { /** @@ -260,7 +265,10 @@ export type ComponentType = (new element?: typeof HTMLElement; }; -declare const SnippetReturn: unique symbol; +/** + * Internal implementation details that vary between environments + */ +export type SnippetInternals = Branded<{}, 'SnippetInternals'>; // Use an interface instead of a type, makes for better intellisense info because the type is named in more situations. /** @@ -277,7 +285,7 @@ declare const SnippetReturn: unique symbol; export interface Snippet { ( this: void, - internal: Branded<{}, 'SnippetInternals'>, + internal: SnippetInternals, // this conditional allows tuples but not arrays. Arrays would indicate a // rest parameter type, which is not supported. If rest parameters are added // in the future, the condition can be removed.