elliott/add-variadic-snippets
S. Elliott Johnson 2 years ago
parent fa49a91cf0
commit d0c61a8596

@ -196,7 +196,10 @@ declare const SnippetReturn: unique symbol;
* You can only call a snippet through the `{@render ...}` tag.
*/
export interface Snippet<T extends unknown[] = []> {
(this: void, ...args: T): typeof SnippetReturn & {
(
this: void,
...args: T
): typeof SnippetReturn & {
_: 'functions passed to {@render ...} tags must use the `Snippet` type imported from "svelte"';
};
}

@ -20,18 +20,18 @@ const d: Snippet<boolean> = (a: string, b: number) => {
const e: Snippet = (a: string) => {
return return_type;
};
// @ts-expect-error
const f: Snippet = (a) => {
// @ts-expect-error
a?.x;
return return_type;
};
const g: Snippet<boolean> = (a) => {
const g: Snippet<[boolean]> = (a) => {
// @ts-expect-error
a === '';
a === true;
return return_type;
};
const h: Snippet<{ a: true }> = (a) => {
const h: Snippet<[{ a: true }]> = (a) => {
a.a === true;
return return_type;
};

Loading…
Cancel
Save