|
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'. |
7 | 7 | 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'. |
14 | 15 | Type 'x is Foo' is not assignable to type 'item is Baz'.
|
15 | 16 | Type 'Foo' is not assignable to type 'Baz'.
|
16 | 17 | Property 'baz' is missing in type 'Foo'.
|
17 | 18 |
|
18 | 19 |
|
19 |
| -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts (12 errors) ==== |
| 20 | +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts (13 errors) ==== |
20 | 21 |
|
21 | 22 | class A {
|
22 | 23 | kind: number;
|
@@ -60,6 +61,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(152,46): err
|
60 | 61 | return true;
|
61 | 62 | }
|
62 | 63 |
|
| 64 | + declare function getObjectOfType<T>(of: (item: any) => item is T, obj: any[]): T; |
| 65 | + |
63 | 66 | function foo(): Foo {
|
64 | 67 | return <Foo>a;
|
65 | 68 | }
|
@@ -171,6 +174,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunction.ts(152,46): err
|
171 | 174 | !!! error TS2339: Property 'baz' does not exist on type 'A'.
|
172 | 175 | }
|
173 | 176 |
|
| 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 | + |
174 | 182 | // The parameter index and argument index for the type guard target is not matching.
|
175 | 183 | if (hasMultipleParameters(0, a)) {
|
176 | 184 | a.foo(); // Error
|
|
0 commit comments