Skip to content

fix: derived types #8700

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

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-pumas-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: derived store types
4 changes: 2 additions & 2 deletions packages/svelte/src/runtime/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function writable(value, start = noop) {
* @template T
* @overload
* @param {S} stores - input stores
* @param {(values: import('./public.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
* @param {(values: import('./private.js').StoresValues<S>, set: (value: T) => void, update: (fn: import('./public.js').Updater<T>) => void) => import('./public.js').Unsubscriber | void} fn - function callback that aggregates the values
Copy link
Member

@dominikg dominikg Jun 8, 2023

Choose a reason for hiding this comment

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

would that make this private type public by referencing it from a signature that is used by runtime ?

Alt: move the type from private to public file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll become a part of the public type but it won't be exported on its own. It was like that previously in v3.

Copy link
Member

Choose a reason for hiding this comment

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

This is one of the things that is a risk for type-drift then. someone editing private.js might not be aware that it is really a public type.

* @param {T} [initial_value] - initial value
* @returns {import('./public.js').Readable<T>}
*/
Expand All @@ -110,7 +110,7 @@ export function writable(value, start = noop) {
* @template T
* @overload
* @param {S} stores - input stores
* @param {(values: import('./public.js').StoresValues<S>) => T} fn - function callback that aggregates the values
* @param {(values: import('./private.js').StoresValues<S>) => T} fn - function callback that aggregates the values
* @param {T} [initial_value] - initial value
* @returns {import('./public.js').Readable<T>}
*/
Expand Down