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
inferContextualTypePredicates1.ts(13,26): error TS2345: Argument of type '(item: Foo | Bar) => false' is not assignable to parameter of type '(a: Foo | Bar) => a is Foo | Bar'.
2
-
Signature '(item: Foo | Bar): false' must be a type predicate.
3
-
inferContextualTypePredicates1.ts(14,26): error TS2345: Argument of type '(item: Foo | Bar) => true' is not assignable to parameter of type '(a: Foo | Bar) => a is Foo | Bar'.
4
-
Signature '(item: Foo | Bar): true' must be a type predicate.
5
1
inferContextualTypePredicates1.ts(17,7): error TS2322: Type '(a: string | null, b: string | null) => boolean' is not assignable to type '(a: string | null, b: string | null) => b is string'.
6
2
Signature '(a: string | null, b: string | null): boolean' must be a type predicate.
!!! error TS2345: Argument of type '(item: Foo | Bar) => true' is not assignable to parameter of type '(a: Foo | Bar) => a is Foo | Bar'.
29
-
!!! error TS2345: Signature '(item: Foo | Bar): true' must be a type predicate.
18
+
const r3 = skipIf(items, (item) => false); // ok
19
+
const r4 = skipIf(items, (item) => true); // ok
30
20
31
21
const pred1: (a: string | null, b: string | null) => b is string = (a, b) => typeof b === 'string'; // ok
32
22
const pred2: (a: string | null, b: string | null) => b is string = (a, b) => typeof a === 'string'; // error
33
23
~~~~~
34
24
!!! error TS2322: Type '(a: string | null, b: string | null) => boolean' is not assignable to type '(a: string | null, b: string | null) => b is string'.
35
25
!!! error TS2322: Signature '(a: string | null, b: string | null): boolean' must be a type predicate.
26
+
27
+
export declare function every<T, U extends T>(array: readonly T[], callback: (element: T, index: number) => element is U): array is readonly U[];
28
+
export declare function every<T, U extends T>(array: readonly T[] | undefined, callback: (element: T, index: number) => element is U): array is readonly U[] | undefined;
constr1=skipIf(items,(item)=>item.type==="foo");// ok
15
15
constr2=skipIf(items,(item)=>item.type==="foo"||item.type==="bar");// ok
16
-
constr3=skipIf(items,(item)=>false);// error
17
-
constr4=skipIf(items,(item)=>true);// error
16
+
constr3=skipIf(items,(item)=>false);// ok
17
+
constr4=skipIf(items,(item)=>true);// ok
18
18
19
19
constpred1: (a: string|null,b: string|null)=>b is string=(a,b)=>typeofb==='string';// ok
20
20
constpred2: (a: string|null,b: string|null)=>b is string=(a,b)=>typeofa==='string';// error
21
+
22
+
exportdeclarefunctionevery<T,UextendsT>(array: readonlyT[],callback: (element: T,index: number)=>element is U): array is readonlyU[];
23
+
exportdeclarefunctionevery<T,UextendsT>(array: readonlyT[]|undefined,callback: (element: T,index: number)=>element is U): array is readonlyU[]|undefined;
0 commit comments