We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createEventDispatcher
It appears that only the last createEventDispatcher produces the type for the listener, they are not merged.
Example:
// Component Foo const dispatchFoo = createEventDispatcher<{foo: string; bar: boolean}>(); const dispatchBar = createEventDispatcher<{bar: string; baz: string}>(); // Component Bar // e is CustomEvent<any> on:foo="{(e) => handleFoo(e.detail.bar)}" // e is CustomEvent<{baz: string}> on:bar="{(e) => handleBar(e.detail.bar)}"
The typescript compiler catches this as expected.
Changing the order produces different results.
if the createEventDispatcher order changes, then the typescript compiler does not catch the error.
// Component Foo const dispatchBar = createEventDispatcher<{bar: string; baz: string}>(); const dispatchFoo = createEventDispatcher<{foo: string; bar: boolean}>(); // Component Bar // e is CustomEvent<{bar: boolean}> on:foo="{(e) => handleFoo(e.detail.bar)}" // e is CustomEvent<any> on:bar="{(e) => handleBar(e.detail.bar)}"
The typescript compiler does not catch the error since the type is now CustomEvent<any>.
CustomEvent<any>
Originally posted by @linuxuser586 in #424 (comment)
The text was updated successfully, but these errors were encountered:
(fix) handle multiple event dispatchers
f9cb4a4
Merge definitions of multiple `createEventDispatcher`-instantations as well as bubbled events. sveltejs#921
(fix) handle multiple event dispatchers (#938)
562c944
Merge definitions of multiple `createEventDispatcher`-instantations as well as bubbled events. #921
No branches or pull requests
It appears that only the last
createEventDispatcher
produces the type for the listener, they are not merged.Example:
The typescript compiler catches this as expected.
Changing the order produces different results.
if the
createEventDispatcher
order changes, then the typescript compiler does not catch the error.The typescript compiler does not catch the error since the type is now
CustomEvent<any>
.Originally posted by @linuxuser586 in #424 (comment)
The text was updated successfully, but these errors were encountered: