Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default export return type #686

Merged
merged 3 commits into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 22 additions & 19 deletions packages/svelte2tsx/svelte-shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,7 @@ declare class Svelte2TsxComponent<
*/
$$slot_def: Slots;
// https://svelte.dev/docs#Client-side_component_API
constructor(options: {
/**
* An HTMLElement to render to. This option is required.
*/
target: Element;
/**
* A child of `target` to render the component immediately before.
*/
anchor?: Element;
/**
* An object of properties to supply to the component.
*/
props?: Props;
hydrate?: boolean;
intro?: boolean;
$$inline?: boolean;
});
constructor(options: Svelte2TsxComponentConstructorParameters<Props>);
/**
* Causes the callback function to be called whenever the component dispatches an event.
* A function is returned that will remove the event listener when called.
Expand All @@ -62,7 +46,26 @@ declare class Svelte2TsxComponent<
$inject_state(): void;
}

type AConstructorTypeOf<T> = new (...args: any[]) => T;
interface Svelte2TsxComponentConstructorParameters<Props extends {}> {
/**
* An HTMLElement to render to. This option is required.
*/
target: Element;
/**
* A child of `target` to render the component immediately before.
*/
anchor?: Element;
/**
* An object of properties to supply to the component.
*/
props?: Props;
hydrate?: boolean;
intro?: boolean;
$$inline?: boolean;
}

type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T;
type SvelteComponentConstructor<T, U extends Svelte2TsxComponentConstructorParameters<any>> = new (options: U) => T;

type SvelteAction<U extends any[], El extends any> = (node: El, ...args:U) => {
update?: (...args:U) => void,
Expand Down Expand Up @@ -174,7 +177,7 @@ declare function __sveltets_each<T>(

declare function createSvelte2TsxComponent<Props, Events, Slots>(
render: () => {props?: Props, events?: Events, slots?: Slots }
): AConstructorTypeOf<Svelte2TsxComponent<Props, Events, Slots>>;
): SvelteComponentConstructor<Svelte2TsxComponent<Props, Events, Slots>,Svelte2TsxComponentConstructorParameters<Props>>;

declare function __sveltets_unwrapArr<T>(arr: ArrayLike<T>): T
declare function __sveltets_unwrapPromiseLike<T>(promise: PromiseLike<T> | T): T