Skip to content

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

Merged
tanhauhau merged 1 commit intosveltejs:masterfrom
AlexGalays:master
Jan 28, 2021
Merged

Swap the order of the two derived store signatures to fix TS inference#5935
tanhauhau merged 1 commit intosveltejs:masterfrom
AlexGalays:master

Conversation

@AlexGalays
Copy link
Copy Markdown
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
Copy Markdown
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