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
other: (_) => {} // outer context-sensitive function
58
+
});
59
+
60
+
// should error
61
+
export const result7 = fn4({
62
+
context: 1,
63
+
~~~~~~~
64
+
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
65
+
!!! related TS6500 contextualTypingGenericFunction2.ts:33:3: The expected type comes from property 'context' which is declared here on type '{ context: boolean; callback: (params: unknown) => (context: boolean, params: unknown) => number; other?: ((arg: string) => void) | undefined; }'
66
+
callback: <N,>(params: N) => {
67
+
return (a: boolean, b) => a ? 1 : 2;
68
+
},
69
+
other: (_) => {} // outer context-sensitive function
70
+
});
71
+
72
+
// should error
73
+
export const result8 = fn4({
74
+
context: 1,
75
+
callback: <N,>(params: N) => {
76
+
~~~~~~~~
77
+
!!! error TS2322: Type '<N>(params: N) => (a: number, b: unknown) => boolean' is not assignable to type '(params: unknown) => (context: number, params: unknown) => number'.
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
80
+
!!! related TS6500 contextualTypingGenericFunction2.ts:34:3: The expected type comes from property 'callback' which is declared here on type '{ context: number; callback: (params: unknown) => (context: number, params: unknown) => number; other?: ((arg: string) => void) | undefined; }'
81
+
return (a, b) => true;
82
+
},
83
+
other: (_) => {} // outer context-sensitive function
0 commit comments