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

Swap the order of the two derived store signatures to fix TS inference #5935

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

AlexGalays
Copy link
Contributor

Before

  • Using derived(store, (value, set) => {}) fails to infer the parameters of the second function (it infers them as any which seems to indicate it picked the simpler signature where the function only has one parameter)
  • All other forms compile fine, even the one with the set param and a start value.

After

  • All combinations compile and infer properly.

I just swapped the order of the two declarations, now forcing TS to consider the more complex signature first.

PS: Have you considered progressively rewriting the tests in typescript to catch these kinds of issues?

Cheers

@tanhauhau tanhauhau merged commit 4d5fe5d into sveltejs:master Jan 28, 2021
@Conduitry
Copy link
Member

Released in 3.32.1, thanks!

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.

4 participants