File: controlFlowInstanceOfGuardPrimitives.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (71 lines) | stat: -rw-r--r-- 2,599 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
=== tests/cases/conformance/controlFlow/controlFlowInstanceOfGuardPrimitives.ts ===
function distinguish(thing: string | number | Date) {
>distinguish : (thing: string | number | Date) => void
>thing : string | number | Date

    if (thing instanceof Object) {
>thing instanceof Object : boolean
>thing : string | number | Date
>Object : ObjectConstructor

        console.log("Aha!! It's a Date in " + thing.getFullYear());
>console.log("Aha!! It's a Date in " + thing.getFullYear()) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>"Aha!! It's a Date in " + thing.getFullYear() : string
>"Aha!! It's a Date in " : "Aha!! It's a Date in "
>thing.getFullYear() : number
>thing.getFullYear : () => number
>thing : Date
>getFullYear : () => number

    } else if (typeof thing === 'string') {
>typeof thing === 'string' : boolean
>typeof thing : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>thing : string | number
>'string' : "string"

        console.log("Aha!! It's a string of length " + thing.length);
>console.log("Aha!! It's a string of length " + thing.length) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>"Aha!! It's a string of length " + thing.length : string
>"Aha!! It's a string of length " : "Aha!! It's a string of length "
>thing.length : number
>thing : string
>length : number

    } else {
        console.log("Aha!! It's the number " + thing.toPrecision(3));
>console.log("Aha!! It's the number " + thing.toPrecision(3)) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>"Aha!! It's the number " + thing.toPrecision(3) : string
>"Aha!! It's the number " : "Aha!! It's the number "
>thing.toPrecision(3) : string
>thing.toPrecision : (precision?: number) => string
>thing : number
>toPrecision : (precision?: number) => string
>3 : 3
    }
}

distinguish(new Date());
>distinguish(new Date()) : void
>distinguish : (thing: string | number | Date) => void
>new Date() : Date
>Date : DateConstructor

distinguish("beef");
>distinguish("beef") : void
>distinguish : (thing: string | number | Date) => void
>"beef" : "beef"

distinguish(3.14159265);
>distinguish(3.14159265) : void
>distinguish : (thing: string | number | Date) => void
>3.14159265 : 3.14159265