Skip to content

Commit 1de2144

Browse files
committed
chore: tests for #8872
1 parent 9086055 commit 1de2144

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/svelte/test/types/actions.ts

+8
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,11 @@ invalidAttributes1;
124124
// @ts-expect-error missing prop
125125
const invalidAttributes2: Attributes = {};
126126
invalidAttributes2;
127+
128+
function generic_action<T extends boolean>(_node: HTMLElement, param: T): ActionReturn<T> {
129+
return {
130+
update: (p) => p === param,
131+
destroy: () => {}
132+
};
133+
}
134+
generic_action;

packages/svelte/test/types/create-event-dispatcher.ts

+21
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,24 @@ dispatch('optional', undefined, { cancelable: true });
4141
dispatch('optional', 'string');
4242
// @ts-expect-error: wrong type of option
4343
dispatch('optional', undefined, { cancelabled: true });
44+
45+
function generic_fn<T extends boolean>(t: T) {
46+
const dispatch = createEventDispatcher<{
47+
required: T;
48+
optional: T | null;
49+
}>();
50+
51+
dispatch('required', t);
52+
dispatch('optional', t);
53+
dispatch('optional', null);
54+
dispatch('optional', undefined);
55+
// @ts-expect-error: wrong type of optional detail
56+
dispatch('optional', 'string');
57+
// @ts-expect-error: wrong type of required detail
58+
dispatch('required', 'string');
59+
// @ts-expect-error: wrong type of optional detail
60+
dispatch('optional', true);
61+
// @ts-expect-error: wrong type of required detail
62+
dispatch('required', true);
63+
}
64+
generic_fn;

0 commit comments

Comments
 (0)