0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-29 08:32:05 +01:00

chore: tests for #8872

This commit is contained in:
Simon Holthausen 2023-06-29 09:35:00 +02:00
parent 90860550ae
commit 1de2144dae
2 changed files with 29 additions and 0 deletions

View File

@ -124,3 +124,11 @@ invalidAttributes1;
// @ts-expect-error missing prop
const invalidAttributes2: Attributes = {};
invalidAttributes2;
function generic_action<T extends boolean>(_node: HTMLElement, param: T): ActionReturn<T> {
return {
update: (p) => p === param,
destroy: () => {}
};
}
generic_action;

View File

@ -41,3 +41,24 @@ dispatch('optional', undefined, { cancelable: true });
dispatch('optional', 'string');
// @ts-expect-error: wrong type of option
dispatch('optional', undefined, { cancelabled: true });
function generic_fn<T extends boolean>(t: T) {
const dispatch = createEventDispatcher<{
required: T;
optional: T | null;
}>();
dispatch('required', t);
dispatch('optional', t);
dispatch('optional', null);
dispatch('optional', undefined);
// @ts-expect-error: wrong type of optional detail
dispatch('optional', 'string');
// @ts-expect-error: wrong type of required detail
dispatch('required', 'string');
// @ts-expect-error: wrong type of optional detail
dispatch('optional', true);
// @ts-expect-error: wrong type of required detail
dispatch('required', true);
}
generic_fn;