Skip to content

Conversation

@dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented May 26, 2021

This change now always marks properties as required if they have no initializer. Previously this was only the case when using TypeScript with strict mode. For this to work for both TS and JS files, the transformation in svelte2tsx was adjusted.

#319
#847

This is a breaking change

The fix is to provide a default value for properties that are optional. That's either the specific value kind or undefined.
Example TS:
export let optional: string;
Becomes
export let optional: string = ''; (or just export let optional = '')
Example JS:
export let optional;
Becomes
export let optional = undefined;

@dummdidumm dummdidumm marked this pull request as ready for review May 27, 2021 11:42
@dummdidumm dummdidumm requested a review from jasonlyu123 May 27, 2021 11:43
Copy link
Member

@jasonlyu123 jasonlyu123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me👍

@dummdidumm dummdidumm merged commit 383c9a2 into sveltejs:master May 28, 2021
@dummdidumm dummdidumm deleted the stricter-required-props branch May 28, 2021 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants