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
Non generic version nonGenericBar works as expected.
functionnonGenericBar(arg: string){returnarg;}vary1=foo1(nonGenericBar);vary2=foo2(nonGenericBar);// Type error
Of course, genericBar function is useless because constraining a type variable to a primitive type can be replaced by a non generic function like nonGenericBar. However, the behaviour is somewhat unexpected and inconsistent.
The following code snippet compiles without type errors though the type variable
Tis constrained tostringtype.Non generic version
nonGenericBarworks as expected.Of course,
genericBarfunction is useless because constraining a type variable to a primitive type can be replaced by a non generic function likenonGenericBar. However, the behaviour is somewhat unexpected and inconsistent.