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:
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…
Reference in New Issue
Block a user