File: inheritedOverloadedSpecializedSignatures.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (120 lines) | stat: -rw-r--r-- 1,734 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
116
117
118
119
120
=== tests/cases/compiler/inheritedOverloadedSpecializedSignatures.ts ===
interface A {
  (key:string):void;
>key : string
}

interface B extends A {
  (key:'foo'):string;
>key : "foo"
}

var b:B;
>b : B

// Should not error
b('foo').charAt(0);
>b('foo').charAt(0) : string
>b('foo').charAt : (pos: number) => string
>b('foo') : string
>b : B
>'foo' : "foo"
>charAt : (pos: number) => string
>0 : 0

interface A {
    (x: 'A1'): string;
>x : "A1"

    (x: string): void;
>x : string
}

interface B extends A {
    (x: 'B1'): number;
>x : "B1"
}

interface A {
    (x: 'A2'): boolean;
>x : "A2"
}

interface B  {
    (x: 'B2'): string[];
>x : "B2"
}

interface C1 extends B {
	(x: 'C1'): number[];
>x : "C1"
}

interface C2 extends B {
	(x: 'C2'): boolean[];
>x : "C2"
}

interface C extends C1, C2 {
	(x: 'C'): string;
>x : "C"
}

var c: C;
>c : C

// none of these lines should error
var x1: string[] = c('B2');
>x1 : string[]
>c('B2') : string[]
>c : C
>'B2' : "B2"

var x2: number = c('B1');
>x2 : number
>c('B1') : number
>c : C
>'B1' : "B1"

var x3: boolean = c('A2');
>x3 : boolean
>c('A2') : boolean
>c : C
>'A2' : "A2"

var x4: string = c('A1');
>x4 : string
>c('A1') : string
>c : C
>'A1' : "A1"

var x5: void = c('A0');
>x5 : void
>c('A0') : void
>c : C
>'A0' : "A0"

var x6: number[] = c('C1');
>x6 : number[]
>c('C1') : number[]
>c : C
>'C1' : "C1"

var x7: boolean[] = c('C2');
>x7 : boolean[]
>c('C2') : boolean[]
>c : C
>'C2' : "C2"

var x8: string = c('C');
>x8 : string
>c('C') : string
>c : C
>'C' : "C"

var x9: void = c('generic');
>x9 : void
>c('generic') : void
>c : C
>'generic' : "generic"