File: assignmentCompatWithConstructSignatures.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 (115 lines) | stat: -rw-r--r-- 2,200 bytes parent folder | download | duplicates (5)
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
113
114
115
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts ===
// void returning call signatures can be assigned a non-void returning call signature that otherwise matches

interface T {
    new (x: number): void;
>x : number
}
var t: T;
>t : T

var a: { new (x: number): void };
>a : new (x: number) => void
>x : number

t = a;
>t = a : new (x: number) => void
>t : T
>a : new (x: number) => void

a = t;
>a = t : T
>a : new (x: number) => void
>t : T

interface S {
    new (x: number): string;
>x : number
}
var s: S;
>s : S

var a2: { new (x: number): string };
>a2 : new (x: number) => string
>x : number

t = s;
>t = s : S
>t : T
>s : S

t = a2;
>t = a2 : new (x: number) => string
>t : T
>a2 : new (x: number) => string

a = s;
>a = s : S
>a : new (x: number) => void
>s : S

a = a2;
>a = a2 : new (x: number) => string
>a : new (x: number) => void
>a2 : new (x: number) => string

interface S2 {
    (x: string): void;
>x : string
}
var s2: S2;
>s2 : S2

var a3: { (x: string): void };
>a3 : (x: string) => void
>x : string

// these are errors
t = s2;
>t = s2 : S2
>t : T
>s2 : S2

t = a3;
>t = a3 : (x: string) => void
>t : T
>a3 : (x: string) => void

t = (x: string) => 1;
>t = (x: string) => 1 : (x: string) => number
>t : T
>(x: string) => 1 : (x: string) => number
>x : string
>1 : 1

t = function (x: string) { return ''; }
>t = function (x: string) { return ''; } : (x: string) => string
>t : T
>function (x: string) { return ''; } : (x: string) => string
>x : string
>'' : ""

a = s2;
>a = s2 : S2
>a : new (x: number) => void
>s2 : S2

a = a3;
>a = a3 : (x: string) => void
>a : new (x: number) => void
>a3 : (x: string) => void

a = (x: string) => 1;
>a = (x: string) => 1 : (x: string) => number
>a : new (x: number) => void
>(x: string) => 1 : (x: string) => number
>x : string
>1 : 1

a = function (x: string) { return ''; }
>a = function (x: string) { return ''; } : (x: string) => string
>a : new (x: number) => void
>function (x: string) { return ''; } : (x: string) => string
>x : string
>'' : ""