You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appreciating the decision to stick with legacy behavior for "initial value" syntax:
export let myProp = "initialValue";
versus true default value syntax:
export let myProp;
$: myProp ??= 'defaultValue';
Could the distinction be made clearer in the Svelte tutorial for default values as it currently teaches that a default value is achieved using the "initial value" syntax?
This difference explains why my TS typing was always complaining that it could not execute functions that were optional props since they could be undefined. And here I am thinking, but they are not undefined since I gave them default values. But typescript knew that those initial values could be over-written back to undefined!!! So now I have to go update all my code.
|| is a boolean operator, calling that "true syntax" is a stretch as you are misusing it and it will misbehave for any values that are coerced to false, e.g. 0 or ''.
Also, the statement should do nothing since it has no assignment.
If anything it should be:
Describe the bug
Appreciating the decision to stick with legacy behavior for "initial value" syntax:
versus true default value syntax:
Could the distinction be made clearer in the Svelte tutorial for default values as it currently teaches that a default value is achieved using the "initial value" syntax?
This difference explains why my TS typing was always complaining that it could not execute functions that were optional props since they could be undefined. And here I am thinking, but they are not undefined since I gave them default values. But typescript knew that those initial values could be over-written back to undefined!!! So now I have to go update all my code.
Reproduction
export let myProp = "initialValue";
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: