-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy patharrayEvery.types
56 lines (51 loc) · 2.65 KB
/
arrayEvery.types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//// [tests/cases/compiler/arrayEvery.ts] ////
=== arrayEvery.ts ===
const foo: (number | string)[] = ['aaa'];
>foo : (string | number)[]
> : ^^^^^^^^^^^^^^^^^^^
>['aaa'] : string[]
> : ^^^^^^^^
>'aaa' : "aaa"
> : ^^^^^
const isString = (x: unknown): x is string => typeof x === 'string';
>isString : (x: unknown) => x is string
> : ^ ^^ ^^^^^
>(x: unknown): x is string => typeof x === 'string' : (x: unknown) => x is string
> : ^ ^^ ^^^^^
>x : unknown
> : ^^^^^^^
>typeof x === 'string' : boolean
> : ^^^^^^^
>typeof x : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined"
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>x : unknown
> : ^^^^^^^
>'string' : "string"
> : ^^^^^^^^
if (foo.every(isString)) {
>foo.every(isString) : boolean
> : ^^^^^^^
>foo.every : { <S extends string | number>(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any): boolean; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^ ^^^
>foo : (string | number)[]
> : ^^^^^^^^^^^^^^^^^^^
>every : { <S extends string | number>(predicate: (value: string | number, index: number, array: (string | number)[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: string | number, index: number, array: (string | number)[]) => unknown, thisArg?: any): boolean; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^ ^^^
>isString : (x: unknown) => x is string
> : ^ ^^ ^^^^^
foo[0].slice(0);
>foo[0].slice(0) : string
> : ^^^^^^
>foo[0].slice : (start?: number, end?: number) => string
> : ^ ^^^ ^^ ^^^ ^^^^^
>foo[0] : string
> : ^^^^^^
>foo : string[]
> : ^^^^^^^^
>0 : 0
> : ^
>slice : (start?: number, end?: number) => string
> : ^ ^^^ ^^ ^^^ ^^^^^
>0 : 0
> : ^
}