File: constEnum3.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 (42 lines) | stat: -rw-r--r-- 901 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
=== tests/cases/conformance/constEnums/constEnum3.ts ===
const enum TestType { foo, bar }
>TestType : TestType
>foo : TestType.foo
>bar : TestType.bar

type TestTypeStr = keyof typeof TestType;
>TestTypeStr : "foo" | "bar"
>TestType : typeof TestType

function f1(f: TestType) { }
>f1 : (f: TestType) => void
>f : TestType

function f2(f: TestTypeStr) { }
>f2 : (f: "foo" | "bar") => void
>f : "foo" | "bar"

f1(TestType.foo)
>f1(TestType.foo) : void
>f1 : (f: TestType) => void
>TestType.foo : TestType.foo
>TestType : typeof TestType
>foo : TestType.foo

f1(TestType.bar)
>f1(TestType.bar) : void
>f1 : (f: TestType) => void
>TestType.bar : TestType.bar
>TestType : typeof TestType
>bar : TestType.bar

f2('foo')
>f2('foo') : void
>f2 : (f: "foo" | "bar") => void
>'foo' : "foo"

f2('bar')
>f2('bar') : void
>f2 : (f: "foo" | "bar") => void
>'bar' : "bar"