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
I want to constrain the reduce callback to only return the same type as the accumulator:
// HotscriptinterfaceCallbackextendsFn{return: 'not a number'// expect to show error}typeT0=Call<T.Reduce<Callback,0>,[1,2,3]>;
Normally when I use recursive type, I can constrain the accumulator type like this. You will get an error if you try to pass a non-number to Acc on recursive calls:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to constrain the reduce callback to only return the same type as the accumulator:
Normally when I use recursive type, I can constrain the accumulator type like this. You will get an error if you try to pass a non-number to
Acc
on recursive calls:Back to Hotscript, below is what I came up with:
but even then there is no connection between my
Accumulator
type and theInit
argument ofT.Reduce
.Beta Was this translation helpful? Give feedback.
All reactions