chore: tests for #8872

pull/8875/head
Simon Holthausen 1 year ago
parent 90860550ae
commit 1de2144dae

@ -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;

@ -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;

Loading…
Cancel
Save