Skip to content

Commit 52b1496

Browse files
committed
Accepts baselines
1 parent 28976a0 commit 52b1496

9 files changed

+174
-91
lines changed

tests/baselines/reference/declFileFunctions.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ export function fooWithSingleOverload(a: any) {
2929
export function fooWithTypePredicate(a: any): a is number {
3030
return true;
3131
}
32+
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
33+
return true;
34+
}
35+
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
36+
return true;
37+
}
38+
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
39+
return true;
40+
}
3241

3342
/** This comment should appear for nonExportedFoo*/
3443
function nonExportedFoo() {
@@ -100,6 +109,22 @@ function fooWithTypePredicate(a) {
100109
return true;
101110
}
102111
exports.fooWithTypePredicate = fooWithTypePredicate;
112+
function fooWithTypePredicateAndMulitpleParams(a, b, c) {
113+
return true;
114+
}
115+
exports.fooWithTypePredicateAndMulitpleParams = fooWithTypePredicateAndMulitpleParams;
116+
function fooWithTypeTypePredicateAndGeneric(a) {
117+
return true;
118+
}
119+
exports.fooWithTypeTypePredicateAndGeneric = fooWithTypeTypePredicateAndGeneric;
120+
function fooWithTypeTypePredicateAndRestParam(a) {
121+
var rest = [];
122+
for (var _i = 1; _i < arguments.length; _i++) {
123+
rest[_i - 1] = arguments[_i];
124+
}
125+
return true;
126+
}
127+
exports.fooWithTypeTypePredicateAndRestParam = fooWithTypeTypePredicateAndRestParam;
103128
/** This comment should appear for nonExportedFoo*/
104129
function nonExportedFoo() {
105130
}
@@ -153,6 +178,9 @@ export declare function fooWithOverloads(a: string): string;
153178
export declare function fooWithOverloads(a: number): number;
154179
export declare function fooWithSingleOverload(a: string): string;
155180
export declare function fooWithTypePredicate(a: any): a is number;
181+
export declare function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number;
182+
export declare function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T;
183+
export declare function fooWithTypeTypePredicateAndRestParam(a: any, ...rest: any[]): a is number;
156184
//// [declFileFunctions_1.d.ts]
157185
/** This comment should appear for foo*/
158186
declare function globalfoo(): void;

tests/baselines/reference/declFileFunctions.symbols

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,50 +64,76 @@ export function fooWithTypePredicate(a: any): a is number {
6464

6565
return true;
6666
}
67+
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
68+
>fooWithTypePredicateAndMulitpleParams : Symbol(fooWithTypePredicateAndMulitpleParams, Decl(declFileFunctions_0.ts, 27, 1))
69+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
70+
>b : Symbol(b, Decl(declFileFunctions_0.ts, 28, 61))
71+
>c : Symbol(c, Decl(declFileFunctions_0.ts, 28, 69))
72+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
73+
74+
return true;
75+
}
76+
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
77+
>fooWithTypeTypePredicateAndGeneric : Symbol(fooWithTypeTypePredicateAndGeneric, Decl(declFileFunctions_0.ts, 30, 1))
78+
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
79+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
80+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
81+
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
82+
83+
return true;
84+
}
85+
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
86+
>fooWithTypeTypePredicateAndRestParam : Symbol(fooWithTypeTypePredicateAndRestParam, Decl(declFileFunctions_0.ts, 33, 1))
87+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
88+
>rest : Symbol(rest, Decl(declFileFunctions_0.ts, 34, 60))
89+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
90+
91+
return true;
92+
}
6793

6894
/** This comment should appear for nonExportedFoo*/
6995
function nonExportedFoo() {
70-
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 27, 1))
96+
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 36, 1))
7197
}
7298
/** This is comment for function signature*/
7399
function nonExportedFooWithParameters(/** this is comment about a*/a: string,
74-
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 31, 1))
75-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 33, 38))
100+
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 40, 1))
101+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
76102

77103
/** this is comment for b*/
78104
b: number) {
79-
>b : Symbol(b, Decl(declFileFunctions_0.ts, 33, 77))
105+
>b : Symbol(b, Decl(declFileFunctions_0.ts, 42, 77))
80106

81107
var d = a;
82-
>d : Symbol(d, Decl(declFileFunctions_0.ts, 36, 7))
83-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 33, 38))
108+
>d : Symbol(d, Decl(declFileFunctions_0.ts, 45, 7))
109+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
84110
}
85111
function nonExportedFooWithRestParameters(a: string, ...rests: string[]) {
86-
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 37, 1))
87-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 38, 42))
88-
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 38, 52))
112+
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 46, 1))
113+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
114+
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
89115

90116
return a + rests.join("");
91-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 38, 42))
117+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
92118
>rests.join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
93-
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 38, 52))
119+
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
94120
>join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
95121
}
96122

97123
function nonExportedFooWithOverloads(a: string): string;
98-
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 40, 1), Decl(declFileFunctions_0.ts, 42, 56), Decl(declFileFunctions_0.ts, 43, 56))
99-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 37))
124+
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
125+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 51, 37))
100126

101127
function nonExportedFooWithOverloads(a: number): number;
102-
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 40, 1), Decl(declFileFunctions_0.ts, 42, 56), Decl(declFileFunctions_0.ts, 43, 56))
103-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 43, 37))
128+
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
129+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 52, 37))
104130

105131
function nonExportedFooWithOverloads(a: any): any {
106-
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 40, 1), Decl(declFileFunctions_0.ts, 42, 56), Decl(declFileFunctions_0.ts, 43, 56))
107-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 44, 37))
132+
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
133+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
108134

109135
return a;
110-
>a : Symbol(a, Decl(declFileFunctions_0.ts, 44, 37))
136+
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
111137
}
112138

113139
=== tests/cases/compiler/declFileFunctions_1.ts ===

tests/baselines/reference/declFileFunctions.types

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,42 @@ export function fooWithSingleOverload(a: any) {
6161
}
6262

6363
export function fooWithTypePredicate(a: any): a is number {
64-
>fooWithTypePredicate : (a: any) => boolean
64+
>fooWithTypePredicate : (a: any) => a is number
6565
>a : any
6666
>a : any
6767

6868
return true;
6969
>true : boolean
7070
}
71+
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
72+
>fooWithTypePredicateAndMulitpleParams : (a: any, b: any, c: any) => a is number
73+
>a : any
74+
>b : any
75+
>c : any
76+
>a : any
77+
78+
return true;
79+
>true : boolean
80+
}
81+
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
82+
>fooWithTypeTypePredicateAndGeneric : <T>(a: any) => a is T
83+
>T : T
84+
>a : any
85+
>a : any
86+
>T : T
87+
88+
return true;
89+
>true : boolean
90+
}
91+
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
92+
>fooWithTypeTypePredicateAndRestParam : (a: any, ...rest: any[]) => a is number
93+
>a : any
94+
>rest : any[]
95+
>a : any
96+
97+
return true;
98+
>true : boolean
99+
}
71100

72101
/** This comment should appear for nonExportedFoo*/
73102
function nonExportedFoo() {

tests/baselines/reference/isArray.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ var maybeArray: number | number[];
55

66
if (Array.isArray(maybeArray)) {
77
>Array.isArray(maybeArray) : boolean
8-
>Array.isArray : (arg: any) => boolean
8+
>Array.isArray : (arg: any) => arg is any[]
99
>Array : ArrayConstructor
10-
>isArray : (arg: any) => boolean
10+
>isArray : (arg: any) => arg is any[]
1111
>maybeArray : number | number[]
1212

1313
maybeArray.length; // OK

tests/baselines/reference/typeGuardFunction.types

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ class C extends A {
2323
}
2424

2525
declare function isA(p1: any): p1 is A;
26-
>isA : (p1: any) => boolean
26+
>isA : (p1: any) => p1 is A
2727
>p1 : any
2828
>p1 : any
2929
>A : A
3030

3131
declare function isB(p1: any): p1 is B;
32-
>isB : (p1: any) => boolean
32+
>isB : (p1: any) => p1 is B
3333
>p1 : any
3434
>p1 : any
3535
>B : B
3636

3737
declare function isC(p1: any): p1 is C;
38-
>isC : (p1: any) => boolean
38+
>isC : (p1: any) => p1 is C
3939
>p1 : any
4040
>p1 : any
4141
>C : C
@@ -55,7 +55,7 @@ var b: B;
5555
// Basic
5656
if (isC(a)) {
5757
>isC(a) : boolean
58-
>isC : (p1: any) => boolean
58+
>isC : (p1: any) => p1 is C
5959
>a : A
6060

6161
a.propC;
@@ -71,7 +71,7 @@ var subType: C;
7171

7272
if(isA(subType)) {
7373
>isA(subType) : boolean
74-
>isA : (p1: any) => boolean
74+
>isA : (p1: any) => p1 is A
7575
>subType : C
7676

7777
subType.propC;
@@ -88,7 +88,7 @@ var union: A | B;
8888

8989
if(isA(union)) {
9090
>isA(union) : boolean
91-
>isA : (p1: any) => boolean
91+
>isA : (p1: any) => p1 is A
9292
>union : A | B
9393

9494
union.propA;
@@ -111,15 +111,15 @@ interface I1 {
111111
// The parameter index and argument index for the type guard target is matching.
112112
// The type predicate type is assignable to the parameter type.
113113
declare function isC_multipleParams(p1, p2): p1 is C;
114-
>isC_multipleParams : (p1: any, p2: any) => boolean
114+
>isC_multipleParams : (p1: any, p2: any) => p1 is C
115115
>p1 : any
116116
>p2 : any
117117
>p1 : any
118118
>C : C
119119

120120
if (isC_multipleParams(a, 0)) {
121121
>isC_multipleParams(a, 0) : boolean
122-
>isC_multipleParams : (p1: any, p2: any) => boolean
122+
>isC_multipleParams : (p1: any, p2: any) => p1 is C
123123
>a : A
124124
>0 : number
125125

@@ -131,10 +131,10 @@ if (isC_multipleParams(a, 0)) {
131131

132132
// Methods
133133
var obj: {
134-
>obj : { func1(p1: A): boolean; }
134+
>obj : { func1(p1: A): p1 is C; }
135135

136136
func1(p1: A): p1 is C;
137-
>func1 : (p1: A) => boolean
137+
>func1 : (p1: A) => p1 is C
138138
>p1 : A
139139
>A : A
140140
>p1 : any
@@ -144,7 +144,7 @@ class D {
144144
>D : D
145145

146146
method1(p1: A): p1 is C {
147-
>method1 : (p1: A) => boolean
147+
>method1 : (p1: A) => p1 is C
148148
>p1 : A
149149
>A : A
150150
>p1 : any
@@ -157,8 +157,8 @@ class D {
157157

158158
// Arrow function
159159
let f1 = (p1: A): p1 is C => false;
160-
>f1 : (p1: A) => boolean
161-
>(p1: A): p1 is C => false : (p1: A) => boolean
160+
>f1 : (p1: A) => p1 is C
161+
>(p1: A): p1 is C => false : (p1: A) => p1 is C
162162
>p1 : A
163163
>A : A
164164
>p1 : any
@@ -167,8 +167,8 @@ let f1 = (p1: A): p1 is C => false;
167167

168168
// Function type
169169
declare function f2(p1: (p1: A) => p1 is C);
170-
>f2 : (p1: (p1: A) => boolean) => any
171-
>p1 : (p1: A) => boolean
170+
>f2 : (p1: (p1: A) => p1 is C) => any
171+
>p1 : (p1: A) => p1 is C
172172
>p1 : A
173173
>A : A
174174
>p1 : any
@@ -177,8 +177,8 @@ declare function f2(p1: (p1: A) => p1 is C);
177177
// Function expressions
178178
f2(function(p1: A): p1 is C {
179179
>f2(function(p1: A): p1 is C { return true;}) : any
180-
>f2 : (p1: (p1: A) => boolean) => any
181-
>function(p1: A): p1 is C { return true;} : (p1: A) => boolean
180+
>f2 : (p1: (p1: A) => p1 is C) => any
181+
>function(p1: A): p1 is C { return true;} : (p1: A) => p1 is C
182182
>p1 : A
183183
>A : A
184184
>p1 : any
@@ -198,21 +198,21 @@ acceptingBoolean(isA(a));
198198
>acceptingBoolean(isA(a)) : any
199199
>acceptingBoolean : (a: boolean) => any
200200
>isA(a) : boolean
201-
>isA : (p1: any) => boolean
201+
>isA : (p1: any) => p1 is A
202202
>a : A
203203

204204
// Type predicates with different parameter name.
205205
declare function acceptingTypeGuardFunction(p1: (item) => item is A);
206-
>acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any
207-
>p1 : (item: any) => boolean
206+
>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any
207+
>p1 : (item: any) => item is A
208208
>item : any
209209
>item : any
210210
>A : A
211211

212212
acceptingTypeGuardFunction(isA);
213213
>acceptingTypeGuardFunction(isA) : any
214-
>acceptingTypeGuardFunction : (p1: (item: any) => boolean) => any
215-
>isA : (p1: any) => boolean
214+
>acceptingTypeGuardFunction : (p1: (item: any) => item is A) => any
215+
>isA : (p1: any) => p1 is A
216216

217217
// Binary expressions
218218
let union2: C | B;
@@ -225,7 +225,7 @@ let union3: boolean | B = isA(union2) || union2;
225225
>B : B
226226
>isA(union2) || union2 : boolean | B
227227
>isA(union2) : boolean
228-
>isA : (p1: any) => boolean
228+
>isA : (p1: any) => p1 is A
229229
>union2 : B | C
230230
>union2 : B
231231

0 commit comments

Comments
 (0)