-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
while dispatching a custom event, following error gets thrown.
index-e29e855b.js:304 Uncaught TypeError: Cannot destructure property 'cancelable' of 'undefined' as it is undefined.
at index-e29e855b.js:304:27
at HTMLButtonElement.decrease (index.svelte-50532f6b.js:84:5)
This happens only when I run svelte-kit build && svelte-kit preview. Its little baffling because svelte source code correctly defines default parameter to the third parameter. However, on build, the default value gets stripped out. I tried with non-minified build also and see the same result.
Workaround: Currently a simple workaround is to pass an empty third parameter to dispatch method.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-9twecw?file=src/lib/Counter.svelte
On the console, cancel the svelte-kit dev process and then start npm run build && npm run preview command.
When - or + button is clicked, a custom dispatch event is called. ideally it should print the show the current count in the parent component. However, on my browser, above error is thrown.
Logs
index-e29e855b.js:304 Uncaught TypeError: Cannot destructure property 'cancelable' of 'undefined' as it is undefined.
at index-e29e855b.js:304:27
at HTMLButtonElement.decrease (index.svelte-50532f6b.js:84:5)System Info
System:
OS: macOS 12.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 75.91 MB / 32.00 GB
Shell: 3.4.1 - /opt/homebrew/bin/fish
Binaries:
Node: 18.1.0 - ~/Library/Caches/fnm_multishells/69089_1652879820227/bin/node
Yarn: 1.22.15 - ~/Library/Caches/fnm_multishells/69089_1652879820227/bin/yarn
npm: 8.8.0 - ~/Library/Caches/fnm_multishells/69089_1652879820227/bin/npm
Browsers:
Chrome: 101.0.4951.64
Chrome Canary: 104.0.5069.0
Firefox: 99.0
Firefox Developer Edition: 101.0
Safari: 15.4
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.43
@sveltejs/kit: next => 1.0.0-next.335
svelte: ^3.48.0 => 3.48.0Severity
annoyance
Additional Information
I thought of raising it in this repo, since the issue is happening during the svelte-kit build.