tp / tsaga

Typesafe and lightweight way to write Redux-connected functions with asynchronous side-effects that are easily testable.
Apache License 2.0
8 stars 1 forks source link

Fix overload types for run and spawn #25

Closed HenriBeck closed 5 years ago

HenriBeck commented 5 years ago

I wasn't able to get the types working without overloads for run and spawn. Right now the types for those functions need to be duplicated in the different environments.

Additionally, this makes the Type names and orders more consistent.

tp commented 5 years ago

Thanks. The parameter type inference already doesn't work in even the simplest case:

https://www.typescriptlang.org/play/#src=function%20twoNumbersOrString%3CT%20extends%20string%20%7C%20number%3E(a%3A%20T%2C%20b%3A%20T%20extends%20number%20%3F%20number%20%3A%20never)%20%7B%0A%20%20%20%20%0A%7D%0A%0AtwoNumbersOrString('string')%0A%0AtwoNumbersOrString(1%2C%202)

I see no way to make it optional. But then, changing the arity of the function without an overload might not be a use-case…

tp commented 5 years ago

@HenriBeck Should we stick with the existing types here then (which are working just fine)?

I haven't see anything on the TypeScript issue tracker that would suggest a fix for conditional parameter types in the near future.

HenriBeck commented 5 years ago

Yeah, if they work, then we don't need to change anything. Though I think before App will use it, we might need to do more cleanup and create documentation, especially around testing.