Merge pull request #3893 from NitayRabi/types---allow-access-to-typed-returned-from--.svelte

Export SvelteComponent as inferred for `*.svelte` files
pull/3928/head
Rich Harris 5 years ago committed by GitHub
commit 5b0b2d9fd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +1,3 @@
declare module '*.svelte' {
type Props = Record<string, any>;
export default class {
constructor(options: {
target: Element;
anchor?: Element;
props?: Props;
hydrate?: boolean;
intro?: boolean;
});
$set(props: Props): void;
$on<T = any>(event: string, callback: (event: CustomEvent<T>) => void): () => void;
$destroy(): void;
[accessor: string]: any;
}
export { SvelteComponentDev as default } from 'svelte/internal';
}

@ -8,5 +8,6 @@ export {
setContext,
getContext,
tick,
createEventDispatcher
createEventDispatcher,
SvelteComponentDev as SvelteComponent
} from 'svelte/internal';

@ -79,8 +79,24 @@ export function set_data_dev(text, data) {
text.data = data;
}
type Props = Record<string, any>;
export interface SvelteComponentDev {
$set(props?: Props): void;
$on<T = any>(event: string, callback: (event: CustomEvent<T>) => void): () => void;
$destroy(): void;
[accessor: string]: any;
}
export class SvelteComponentDev extends SvelteComponent {
constructor(options) {
constructor(options: {
target: Element;
anchor?: Element;
props?: Props;
hydrate?: boolean;
intro?: boolean;
$$inline?: boolean;
}) {
if (!options || (!options.target && !options.$$inline)) {
throw new Error(`'target' is a required option`);
}
@ -103,4 +119,4 @@ export function loop_guard(timeout) {
throw new Error(`Infinite loop detected`);
}
};
}
}

Loading…
Cancel
Save