pull/5738/head
Simon Holthausen 5 years ago
parent c4b15724f5
commit 955862320c

@ -212,6 +212,9 @@ if (typeof HTMLElement === 'function') {
};
}
/**
* Base class for Svelte components. Used when dev=false.
*/
export class SvelteComponent {
$$: T$$;
$$set?: ($$props: any) => void;

@ -104,7 +104,9 @@ export interface SvelteComponentDev {
$destroy(): void;
[accessor: string]: any;
}
/**
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
*/
export class SvelteComponentDev extends SvelteComponent {
/**
* @private
@ -151,6 +153,29 @@ export interface SvelteComponentTyped<
$destroy(): void;
[accessor: string]: any;
}
/**
* Base class to create strongly typed Svelte components.
* This only exists for typing purposes and should be used in `.d.ts` files.
*
* Example:
*
* You have component library on npm called `component-library`, from which
* you export a component called `MyComponent`. For Svelte+TypeScript users,
* you want to provide typings. Therefore you create a `index.d.ts`:
* ```ts
* import { SvelteComponentTyped } from "svelte";
* export class MyComponent extends SvelteComponentTyped<{foo: string}> {}
* ```
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
* to provide intellisense and to use the component like this in a Svelte file
* with TypeScript:
* ```svelte
* <script lang="ts">
* import { MyComponent } from "component-library";
* </script>
* <MyComponent foo={'bar'} />
* ```
*/
export class SvelteComponentTyped<
Props extends Record<string, any> = any,
Events extends Record<string, any> = any,

Loading…
Cancel
Save