File: unionTypeCallSignatures4.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (112 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download | duplicates (3)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
=== tests/cases/conformance/types/union/unionTypeCallSignatures4.ts ===
type F1 = (a: string, b?: string) => void;
>F1 : (a: string, b?: string) => void
>a : string
>b : string

type F2 = (a: string, b?: string, c?: string) => void;
>F2 : (a: string, b?: string, c?: string) => void
>a : string
>b : string
>c : string

type F3 = (a: string, ...rest: string[]) => void;
>F3 : (a: string, ...rest: string[]) => void
>a : string
>rest : string[]

type F4 = (a: string, b?: string, ...rest: string[]) => void;
>F4 : (a: string, b?: string, ...rest: string[]) => void
>a : string
>b : string
>rest : string[]

type F5 = (a: string, b: string) => void;
>F5 : (a: string, b: string) => void
>a : string
>b : string

var f12: F1 | F2;
>f12 : F1 | F2

f12("a");
>f12("a") : void
>f12 : F1 | F2
>"a" : "a"

f12("a", "b");
>f12("a", "b") : void
>f12 : F1 | F2
>"a" : "a"
>"b" : "b"

f12("a", "b", "c");  // ok
>f12("a", "b", "c") : void
>f12 : F1 | F2
>"a" : "a"
>"b" : "b"
>"c" : "c"

var f34: F3 | F4;
>f34 : F3 | F4

f34("a");
>f34("a") : void
>f34 : F3 | F4
>"a" : "a"

f34("a", "b");
>f34("a", "b") : void
>f34 : F3 | F4
>"a" : "a"
>"b" : "b"

f34("a", "b", "c");
>f34("a", "b", "c") : void
>f34 : F3 | F4
>"a" : "a"
>"b" : "b"
>"c" : "c"

var f1234: F1 | F2 | F3 | F4;
>f1234 : F1 | F2 | F3 | F4

f1234("a");
>f1234("a") : void
>f1234 : F1 | F2 | F3 | F4
>"a" : "a"

f1234("a", "b");
>f1234("a", "b") : void
>f1234 : F1 | F2 | F3 | F4
>"a" : "a"
>"b" : "b"

f1234("a", "b", "c");  // ok
>f1234("a", "b", "c") : void
>f1234 : F1 | F2 | F3 | F4
>"a" : "a"
>"b" : "b"
>"c" : "c"

var f12345: F1 | F2 | F3 | F4 | F5;
>f12345 : F1 | F2 | F3 | F4 | F5

f12345("a");  // error
>f12345("a") : void
>f12345 : F1 | F2 | F3 | F4 | F5
>"a" : "a"

f12345("a", "b");
>f12345("a", "b") : void
>f12345 : F1 | F2 | F3 | F4 | F5
>"a" : "a"
>"b" : "b"

f12345("a", "b", "c");  // error
>f12345("a", "b", "c") : void
>f12345 : F1 | F2 | F3 | F4 | F5
>"a" : "a"
>"b" : "b"
>"c" : "c"