Skip to content

Commit 96a17fa

Browse files
committed
Accept baselines
1 parent fef407d commit 96a17fa

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

tests/baselines/reference/typeGuardFunction.errors.txt

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(101,12): error TS2322: Type 'string' is not assignable to type 'x is A'.
2-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(104,55): error TS1220: Can't define a type-guard type inside a type-guard type.
3-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(108,32): error TS2304: Cannot find name 'x'.
4-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(112,48): error TS1219: Type declaration expected.
5-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(116,38): error TS2504: Type-guard target must have a matching parameter.
6-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(120,51): error TS2322: Type 'B' is not assignable to type 'A'.
1+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(103,12): error TS2322: Type 'string' is not assignable to type 'x is A'.
2+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(106,55): error TS1220: Can't define a type-guard type inside a type-guard type.
3+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(110,32): error TS2304: Cannot find name 'x'.
4+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(114,48): error TS1219: Type declaration expected.
5+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(118,38): error TS2504: Type-guard target must have a matching parameter.
6+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(122,51): error TS2322: Type 'B' is not assignable to type 'A'.
77
Property 'kind' is missing in type 'B'.
8-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(124,56): error TS2322: Type 'number' is not assignable to type 'string'.
9-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(128,56): error TS2322: Type 'T[]' is not assignable to type 'string'.
10-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(133,7): error TS2339: Property 'baz' does not exist on type 'A'.
11-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(138,7): error TS2339: Property 'foo' does not exist on type 'A'.
12-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(145,7): error TS2339: Property 'foo' does not exist on type 'A'.
13-
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(152,46): error TS2345: Argument of type '(x: A) => x is Foo' is not assignable to parameter of type '(item: any) => item is Baz'.
8+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(126,56): error TS2322: Type 'number' is not assignable to type 'string'.
9+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(130,56): error TS2322: Type 'T[]' is not assignable to type 'string'.
10+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(135,7): error TS2339: Property 'baz' does not exist on type 'A'.
11+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(139,5): error TS2322: Type 'Foo' is not assignable to type 'string'.
12+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(143,7): error TS2339: Property 'foo' does not exist on type 'A'.
13+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(150,7): error TS2339: Property 'foo' does not exist on type 'A'.
14+
tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(157,46): error TS2345: Argument of type '(x: A) => x is Foo' is not assignable to parameter of type '(item: any) => item is Baz'.
1415
Type 'x is Foo' is not assignable to type 'item is Baz'.
1516
Type 'Foo' is not assignable to type 'Baz'.
1617
Property 'baz' is missing in type 'Foo'.
1718

1819

19-
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts (12 errors) ====
20+
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts (13 errors) ====
2021

2122
class A {
2223
kind: number;
@@ -60,6 +61,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(152,46): err
6061
return true;
6162
}
6263

64+
declare function getObjectOfType<T>(of: (item: any) => item is T, obj: any[]): T;
65+
6366
function foo(): Foo {
6467
return <Foo>a;
6568
}
@@ -171,6 +174,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(152,46): err
171174
!!! error TS2339: Property 'baz' does not exist on type 'A'.
172175
}
173176

177+
// Error: Type Foo is not assignable to string
178+
var f: string = getObjectOfType(isFoo, [1, 2]);
179+
~
180+
!!! error TS2322: Type 'Foo' is not assignable to type 'string'.
181+
174182
// The parameter index and argument index for the type guard target is not matching.
175183
if (hasMultipleParameters(0, a)) {
176184
a.foo(); // Error

tests/baselines/reference/typeGuardFunction.js

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function isArrayOf_2<T>(of: (item) => item is T, a: any[]): a is T[] {
4242
return true;
4343
}
4444

45+
declare function getObjectOfType<T>(of: (item: any) => item is T, obj: any[]): T;
46+
4547
function foo(): Foo {
4648
return <Foo>a;
4749
}
@@ -134,6 +136,9 @@ if (isBaz(b)) {
134136
a.baz(); // Error
135137
}
136138

139+
// Error: Type Foo is not assignable to string
140+
var f: string = getObjectOfType(isFoo, [1, 2]);
141+
137142
// The parameter index and argument index for the type guard target is not matching.
138143
if (hasMultipleParameters(0, a)) {
139144
a.foo(); // Error
@@ -282,6 +287,8 @@ function hasNonMathcingGenericType(a) {
282287
if (isBaz(b)) {
283288
a.baz(); // Error
284289
}
290+
// Error: Type Foo is not assignable to string
291+
var f = getObjectOfType(isFoo, [1, 2]);
285292
// The parameter index and argument index for the type guard target is not matching.
286293
if (hasMultipleParameters(0, a)) {
287294
a.foo(); // Error

tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ if (isBaz(b)) {
135135
a.baz(); // Error
136136
}
137137

138-
// Error: Type Foo is not assignable to string
139-
var f: string = getObjectOfType(isFoo, [1, 2]);
138+
// Error: Type Foo is not assignable to string
139+
var f: string = getObjectOfType(isFoo, [1, 2]);
140140

141141
// The parameter index and argument index for the type guard target is not matching.
142142
if (hasMultipleParameters(0, a)) {

0 commit comments

Comments
 (0)