Skip to content

Commit 6d04a5b

Browse files
committed
hide helper type from public api
1 parent b9ee487 commit 6d04a5b

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

packages/svelte/src/index.d.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).
22

3+
import './ambient.js';
4+
import type { RemoveBindable } from './internal/types.js';
5+
36
/**
47
* @deprecated Svelte components were classes in Svelte 4. In Svelte 5, thy are not anymore.
58
* Use `mount` or `createRoot` instead to instantiate components.
@@ -27,12 +30,6 @@ type WithBindings<T> = {
2730
[Key in keyof T]: Bindable<T[Key]>;
2831
};
2932

30-
export type RemoveBindable<Props extends Record<string, any>> = {
31-
[Key in keyof Props as Props[Key] extends Binding<unknown>
32-
? never
33-
: Key]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
34-
};
35-
3633
type StripBindable<Props extends Record<string, any>> = {
3734
[Key in keyof Props]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
3835
};
@@ -252,4 +249,3 @@ export interface EventDispatcher<EventMap extends Record<string, any>> {
252249
}
253250

254251
export * from './index-client.js';
255-
import './ambient.js';

packages/svelte/src/internal/client/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function stringify(value) {
9292
* @param {{
9393
* target: Document | Element | ShadowRoot;
9494
* anchor?: Node;
95-
* props?: import('../../index.js').RemoveBindable<Props>;
95+
* props?: import('../types.js').RemoveBindable<Props>;
9696
* events?: { [Property in keyof Events]: (e: Events[Property]) => any };
9797
* context?: Map<any, any>;
9898
* intro?: boolean;
@@ -114,7 +114,7 @@ export function mount(component, options) {
114114
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent<Props, Events>>} component
115115
* @param {{
116116
* target: Document | Element | ShadowRoot;
117-
* props?: import('../../index.js').RemoveBindable<Props>;
117+
* props?: import('../types.js').RemoveBindable<Props>;
118118
* events?: { [Property in keyof Events]: (e: Events[Property]) => any };
119119
* context?: Map<any, any>;
120120
* intro?: boolean;
@@ -182,7 +182,7 @@ export function hydrate(component, options) {
182182

183183
/**
184184
* @template {Record<string, any>} Exports
185-
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent>} Component
185+
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent<any>>} Component
186186
* @param {{
187187
* target: Document | Element | ShadowRoot;
188188
* anchor: Node;

packages/svelte/src/internal/client/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Bindable, Binding } from '../../index.js';
12
import type { Store } from '#shared';
23
import { STATE_SYMBOL } from './constants.js';
34
import type { Effect, Source, Value } from './reactivity/types.js';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1+
import type { Bindable, Binding } from '../index.js';
2+
13
/** Anything except a function */
24
export type NotFunction<T> = T extends Function ? never : T;
5+
6+
export type RemoveBindable<Props extends Record<string, any>> = {
7+
[Key in keyof Props as Props[Key] extends Binding<unknown>
8+
? never
9+
: Key]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
10+
};

packages/svelte/types/index.d.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
declare module 'svelte' {
2-
// This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).
3-
42
/**
53
* @deprecated Svelte components were classes in Svelte 4. In Svelte 5, thy are not anymore.
64
* Use `mount` or `createRoot` instead to instantiate components.
@@ -28,12 +26,6 @@ declare module 'svelte' {
2826
[Key in keyof T]: Bindable<T[Key]>;
2927
};
3028

31-
export type RemoveBindable<Props extends Record<string, any>> = {
32-
[Key in keyof Props as Props[Key] extends Binding<unknown>
33-
? never
34-
: Key]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
35-
};
36-
3729
type StripBindable<Props extends Record<string, any>> = {
3830
[Key in keyof Props]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
3931
};
@@ -251,6 +243,14 @@ declare module 'svelte' {
251243
: [type: Type, parameter: EventMap[Type], options?: DispatchOptions]
252244
): boolean;
253245
}
246+
/** Anything except a function */
247+
type NotFunction<T> = T extends Function ? never : T;
248+
249+
type RemoveBindable<Props extends Record<string, any>> = {
250+
[Key in keyof Props as Props[Key] extends Binding<unknown>
251+
? never
252+
: Key]: Props[Key] extends Bindable<infer Value> ? Value : Props[Key];
253+
};
254254
/**
255255
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
256256
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
@@ -321,8 +321,6 @@ declare module 'svelte' {
321321
* Synchronously flushes any pending state changes and those that result from it.
322322
* */
323323
export function flushSync(fn?: (() => void) | undefined): void;
324-
/** Anything except a function */
325-
type NotFunction<T> = T extends Function ? never : T;
326324
/**
327325
* Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
328326
*

0 commit comments

Comments
 (0)