You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript error Type '{}' is not assignable to type 'number'.
Provide a minimal sample reproduction. Create a reproduction based on this sandbox
Seems like generics for action not really working well. In real project I am triggering some simple action on rxjs subscription. But I created small example to show you the issue. I tried to duplicate your code for IActionFactory so it will be easier to understand the rootcause.
Did you check this issue wasn't filed before?
Elaborate on your issue. What behavior did you expect?
I expect TS to not throw error, because it have already all info about my types.
Idea:
What problem would it solve for you?
For real, problem is not so huge, I just need to define some types for action, and TS will understand what is going on. But it would be great, if everything would work without strict types declaration.
Do you think others will benefit from this change as well and it should in core package (see also mobx-utils)?
Are you willing to (attempt) a PR yourself?
I found out, that issue will dissappear, if I will move generic types at top, like here, but I'm not sure about full impact of this change, so decided ask you about this issue. Maybe I'm doing something wrong? Because I'm not fully understand, why do we need these types
<A1, R, T extends (a1: A1) => R>(fn: T): T & IAction
<A1, A2, R, T extends (a1: A1, a2: A2) => R>(fn: T): T & IAction
<A1, A2, A3, R, T extends (a1: A1, a2: A2, a3: A3) => R>(fn: T): T & IAction
<A1, A2, A3, A4, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4) => R>(fn: T): T & IAction
<A1, A2, A3, A4, A5, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => R>(fn: T): T &
IAction
<A1, A2, A3, A4, A5, A6, R, T extends (a1: A1, a2: A2, a3: A3, a4: A4, a6: A6) => R>(fn: T): T &
IAction
while we can use only
<T extends Function>(fn: T): T & IAction
The text was updated successfully, but these errors were encountered:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
lockbot
locked as resolved and limited conversation to collaborators
Jul 21, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have a:
TypeScript error
Type '{}' is not assignable to type 'number'.
Seems like generics for
action
not really working well. In real project I am triggering some simpleaction
on rxjs subscription. But I created small example to show you the issue. I tried to duplicate your code forIActionFactory
so it will be easier to understand the rootcause.I expect TS to not throw error, because it have already all info about my types.
For real, problem is not so huge, I just need to define some types for
action
, and TS will understand what is going on. But it would be great, if everything would work without strict types declaration.I found out, that issue will dissappear, if I will move generic types at top, like here, but I'm not sure about full impact of this change, so decided ask you about this issue. Maybe I'm doing something wrong? Because I'm not fully understand, why do we need these types
while we can use only
The text was updated successfully, but these errors were encountered: