-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Control flow breaks inside event handler lambda functions - intended or not? #876
Comments
The svelte syntax mimics if statements rather than conditionals |
I would agree. I am making a component that morphs based on the type of the provided variable, and I really expected that this would work. Not my preference, but allowing for some kind of |
Control flow for TypeScript now should work correctly almost everywhere. One exception are event handlers when they use lambda functions.
To Reproduce
Expected behavior
Now the question is: Is this a bug or standard TypeScript behavior?
One could argue it's a bug because one never gets to the click handler if the value is
null
.One could also argue it's standard TypeScript behavior because the following React snippet will also yell at you:
The reason is that TypeScript does not know when that lambda-function is invoked, so it cannot say for sure that
value
has not changed in the meantime because it's not aconst
.Thoughts on this welcome!
System (please complete the following information):
Svelte for VS Code 104.6.4 /
svelte-check
svelte-check-1.2.5The text was updated successfully, but these errors were encountered: