File: stringLiteralTypesInUnionTypes01.types

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download | duplicates (2)
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
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts ===

type T = "foo" | "bar" | "baz";
>T : "foo" | "bar" | "baz"

var x: "foo" | "bar" | "baz" = undefined;
>x : "foo" | "bar" | "baz"
>undefined : undefined

var y: T = undefined;
>y : "foo" | "bar" | "baz"
>T : "foo" | "bar" | "baz"
>undefined : undefined

if (x === "foo") {
>x === "foo" : boolean
>x : "foo" | "bar" | "baz"
>"foo" : "foo"

    let a = x;
>a : "foo"
>x : "foo"
}
else if (x !== "bar") {
>x !== "bar" : boolean
>x : "bar" | "baz"
>"bar" : "bar"

    let b = x || y;
>b : "foo" | "bar" | "baz"
>x || y : "foo" | "bar" | "baz"
>x : "baz"
>y : "foo" | "bar" | "baz"
}
else {
    let c = x;
>c : "bar"
>x : "bar"

    let d = y;
>d : "foo" | "bar" | "baz"
>y : "foo" | "bar" | "baz"

    let e: (typeof x) | (typeof y) = c || d;
>e : "foo" | "bar" | "baz"
>x : "bar"
>y : "foo" | "bar" | "baz"
>c || d : "foo" | "bar" | "baz"
>c : "bar"
>d : "foo" | "bar" | "baz"
}

x = y;
>x = y : "foo" | "bar" | "baz"
>x : "foo" | "bar" | "baz"
>y : "foo" | "bar" | "baz"

y = x;
>y = x : "foo" | "bar" | "baz"
>y : "foo" | "bar" | "baz"
>x : "foo" | "bar" | "baz"