-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte 5, an error should be thrown when event isn't defined #10393
New issue
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
Comments
Could you clarify what you expect to happen here? If I focus the input I already see an error in the console. Are you talking about wanting a red squiggly in your editor? |
Intuitively I'd expect an error that It becomes more clear if you do this: <script>
import TogglePopover from "./TogglePopover.svelte";
+ window.onfocus = console.log.bind(window, 'focus')
</script>
<TogglePopover>
<input type="text" placeholder="Select Search" {onfocus} />
</TogglePopover> |
Seems we're not the only ones with this problem, and there is no good solution in sight: microsoft/TypeScript#14306 |
@dummdidumm how exactly is this related to TypeScript (serious question, the REPL doesn't use TypeScript)? In early Svelte versions you've kept a list of globals: svelte/src/compiler/compile/Component.ts Line 1445 in 5665f71
how does this work now? The |
We removed the globals list because it resulted in too many false positives - in a world where everybody is using typed JavaScript it's better to defer to these tools instead. |
* fix: warn against accidental global event referenced closes #10393 * remove list * remove else * tweak * update test --------- Co-authored-by: Rich Harris <[email protected]>
Describe the bug
When working with children snippets and event bubbling an error should be thrown if event isn't defined.
Since I was passing onfocus to the children snippet, the snippet needed to be defined explicitly so that onfocus is defined:
Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE5WRQWvDMAyF_4oQg6YQknubhu2426C7zTukjtIYHMs4SrcR8t9HmrRrNhjb0U9PT_rkHitjqcXNS4-uaAg3-OA9xigffny0J7JCGGPLXdCjkrU6GC-5ckpM4zkI7MmSlj0VQddQBW5glaS3YjLFrLbKZelXv8t8_ghvhRMQhkN3OFgCqQnYVay7FuhETsC45QRheObj0dITez5RyFI_pS1caY4xNlyaylCJGwkdDfEV8tb6T9rF7AlXYZIu5BlY4Q_ihe0cmxnnO4FxhZ1CoXdRCN4Wmmq2JYWdmreFaV2F0M8HGiDNxwHL0N-4F86_glsS6EHXxpaBHAywgzsf2LfRenupk6Vm1FsphCLXWXuuOYCqc1oMu8uvRrSGfmxTotm1bCmxfIxWBJs8h1UMNKUO307X3wdyJYXrItEcuB5-Er8On469s5naAgAA
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: