Skip to content
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

First argument to writable/readable should be optional #6291

Closed
Rich-Harris opened this issue May 3, 2021 · 1 comment · Fixed by #6293
Closed

First argument to writable/readable should be optional #6291

Rich-Harris opened this issue May 3, 2021 · 1 comment · Fixed by #6293

Comments

@Rich-Harris
Copy link
Member

Describe the bug
It's totally valid to create a store without an initial value, but TypeScript complains:

image

Expected behavior
store = writable() etc should be accepted by TypeScript. I guess value: T here just needs to be value?: T (and similarly for readable)?

export function writable<T>(value: T, start: StartStopNotifier<T> = noop): Writable<T> {

Information about your Svelte project:
It's a SvelteKit project using [email protected]

Severity
Minor — easily worked around with writable(undefined)

dummdidumm pushed a commit that referenced this issue May 20, 2021
Fixes #6291
Fixes #6345

Both writable and readable initialized without any arguments are already valid, but TS complains about it. This makes both allowed to be emptily initialized. It's also possible to invoke readable with one argument only.
@Conduitry
Copy link
Member

The types have been updated in 3.38.3 to indicate that the first argument is optional.

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 a pull request may close this issue.

2 participants