8000 Accepted baselines. · johnangularjs/TypeScript@b7c399c · GitHub
[go: up one dir, main page]

Skip to content

Commit b7c399c

Browse files
Accepted baselines.
1 parent b10733b commit b7c399c

8 files changed

+378
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates01.ts(21,1): error TS2322: Type '(x: any) => x is B' is not assignable to type '(x: any) => x is A'.
2+
Type predicate 'x is B' is not assignable to 'x is A'.
3+
Type 'B' is not assignable to type 'A'.
4+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates01.ts(22,1): error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is B'.
5+
Type predicate 'x is A' is not assignable to 'x is B'.
6+
Type 'A' is not assignable to type 'B'.
7+
8+
9+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates01.ts (2 errors) ====
10+
11+
class A {
12+
private a;
13+
}
14+
15+
class B extends A {
16+
private b;
17+
}
18+
19+
function isA(x: any): x is A {
20+
return x instanceof A;
21+
}
22+
23+
function i 8000 sB(x: any): x is B {
24+
return x instanceof B;
25+
}
26+
27+
let myIsA = isA;
28+
let myIsB = isB;
29+
30+
myIsA = myIsB;
31+
~~~~~
32+
!!! error TS2322: Type '(x: any) => x is B' is not assignable to type '(x: any) => x is A'.
33+
!!! error TS2322: Type predicate 'x is B' is not assignable to 'x is A'.
34+
!!! error TS2322: Type 'B' is not assignable to type 'A'.
35+
myIsB = myIsA;
36+
~~~~~
37+
!!! error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is B'.
38+
!!! error TS2322: Type predicate 'x is A' is not assignable to 'x is B'.
39+
!!! error TS2322: Type 'A' is not assignable to type 'B'.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//// [assignmentCompatForSignaturesWithTypePredicates01.ts]
2+
3+
class A {
4+
private a;
5+
}
6+
7+
class B extends A {
8+
private b;
9+
}
10+
11+
function isA(x: any): x is A {
12+
return x instanceof A;
13+
}
14+
15+
function isB(x: any): x is B {
16+
return x instanceof B;
17+
}
18+
19+
let myIsA = isA;
20+
let myIsB = isB;
21+
22+
myIsA = myIsB;
23+
myIsB = myIsA;
24+
25+
//// [assignmentCompatForSignaturesWithTypePredicates01.js]
26+
var __extends = (this && this.__extends) || function (d, b) {
27+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
28+
function __() { this.constructor = d; }
29+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30+
};
31+
var A = (function () {
32+
function A() {
33+
}
34+
return A;
35+
})();
36+
var B = (function (_super) {
37+
__extends(B, _super);
38+
function B() {
39+
_super.apply(this, arguments);
40+
}
41+
return B;
42+
})(A);
43+
function isA(x) {
44+
return x instanceof A;
45+
}
46+
function isB(x) {
47+
return x instanceof B;
48+
}
49+
var myIsA = isA;
50+
var myIsB = isB;
51+
myIsA = myIsB;
52+
myIsB = myIsA;
53+
54+
55+
//// [assignmentCompatForSignaturesWithTypePredicates01.d.ts]
56+
declare class A {
57+
private a;
58+
}
59+
declare class B extends A {
60+
private b;
61+
}
62+
declare function isA(x: any): x is A;
63+
declare function isB(x: any): x is B;
64+
declare let myIsA: typeof isA;
65+
declare let myIsB: typeof isB;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates02.ts(11,25): error TS2304: Cannot find name 'B'.
2+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates02.ts(17,1): error TS2322: Type '(x: any) => x is any' is not assignable to type '(x: any) => x is A'.
3+
Type predicate 'x is any' is not assignable to 'x is A'.
4+
Type 'any' is not assignable to type 'A'.
5+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates02.ts(18,1): error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is any'.
6+
Type predicate 'x is A' is not assignable to 'x is any'.
7+
Type 'A' is not assignable to type 'any'.
8+
9+
10+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates02.ts (3 errors) ====
11+
12+
class A {
13+
private a;
14+
}
15+
16+
function isA(x: any): x is A {
17+
return x instanceof A;
18+
}
19+
20+
function isAny(x: any): x is any {
21+
return x instanceof B;
22+
~
23+
!!! error TS2304: Cannot find name 'B'.
24+
}
25+
26+
let myIsA = isA;
27+
let myIsAny = isAny;
28+
29+
myIsA = myIsAny;
30+
~~~~~
31+
!!! error TS2322: Type '(x: any) => x is any' is not assignable to type '(x: any) => x is A'.
32+
!!! error TS2322: Type predicate 'x is any' is not assignable to 'x is A'.
33+
!!! error TS2322: Type 'any' is not assignable to type 'A'.
34+
myIsAny = myIsA;
35+
~~~~~~~
36+
!!! error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is any'.
37+
!!! error TS2322: Type predicate 'x is A' is not assignable to 'x is any'.
38+
!!! error TS2322: Type 'A' is not assignable to type 'any'.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [assignmentCompatForSignaturesWithTypePredicates02.ts]
2+
3+
class A {
4+
private a;
5+
}
6+
7+
function isA(x: any): x is A {
8+
return x instanceof A;
9+
}
10+
11+
function isAny(x: any): x is any {
12+
return x instanceof B;
13+
}
14+
15+
let myIsA = isA;
16+
let myIsAny = isAny;
17+
18+
myIsA = myIsAny;
19+
myIsAny = myIsA;
20+
21+
//// [assignmentCompatForSignaturesWithTypePredicates02.js]
22+
var A = (function () {
23+
function A() {
24+
}
25+
return A;
26+
})();
27+
function isA(x) {
28+
return x instanceof A;
29+
}
30+
function isAny(x) {
31+
return x instanceof B;
32+
}
33+
var myIsA = isA;
34+
var myIsAny = isAny;
35+
myIsA = myIsAny;
36+
myIsAny = myIsA;
37+
38+
39+
//// [assignmentCompatForSignaturesWithTypePredicates02.d.ts]
40+
declare class A {
41+
private a;
42+
}
43+
declare function isA(x: any): x is A;
44+
declare function isAny(x: any): x is any;
45+
declare let myIsA: typeof isA;
46+
declare let myIsAny: typeof isAny;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates03.ts(20,1): error TS2322: Type '(x: any) => x is B' is not assignable to type '(x: any) => x is A'.
2+
Type predicate 'x is B' is not assignable to 'x is A'.
3+
Type 'B' is not assignable to type 'A'.
4+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates03.ts(21,1): error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is B'.
5+
Type predicate 'x is A' is not assignable to 'x is B'.
6+
Type 'A' is not assignable to type 'B'.
7+
8+
9+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates03.ts (2 errors) ====
10+
11+
interface A {
12+
a?;
13+
}
14+
15+
interface B {
16+
}
17+
18+
function isA(x: any): x is A {
19+
return !!(<A>x).a;
20+
}
21+
22+
function isB(x: any): x is B {
23+
return !!isA(x);
24+
}
25+
26+
let myIsA = isA;
27+
let myIsAny = isB;
28+
29+
myIsA = myIsAny;
30+
~~~~~
31+
!!! error TS2322: Type '(x: any) => x is B' is not assignable to type '(x: any) => x is A'.
32+
!!! error TS2322: Type predicate 'x is B' is not assignable to 'x is A'.
33+
!!! error TS2322: Type 'B' is not assignable to type 'A'.
34+
myIsAny = myIsA;
35+
~~~~~~~
36+
!!! error TS2322: Type '(x: any) => x is A' is not assignable to type '(x: any) => x is B'.
37+
!!! error TS2322: Type predicate 'x is A' is not assignable to 'x is B'.
38+
!!! error TS2322: Type 'A' is not assignable to type 'B'.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [assignmentCompatForSignaturesWithTypePredicates03.ts]
2+
3+
interface A {
4+
a?;
5+
}
6+
7+
interface B {
8+
}
9+
10+
function isA(x: any): x is A {
11+
return !!(<A>x).a;
12+
}
13+
14+
function isB(x: any): x is B {
15+
return !!isA(x);
16+
}
17+
18+
let myIsA = isA;
19+
let myIsAny = isB;
20+
21+
myIsA = myIsAny;
22+
myIsAny = myIsA;
23+
24+
//// [assignmentCompatForSignaturesWithTypePredicates03.js]
25+
function isA(x) {
26+
return !!x.a;
27+
}
28+
function isB(x) {
29+
return !!isA(x);
30+
}
31+
var myIsA = isA;
32+
var myIsAny = isB;
33+
myIsA = myIsAny;
34+
myIsAny = myIsA;
35+
36+
37+
//// [assignmentCompatForSignaturesWithTypePredicates03.d.ts]
38+
interface A {
39+
a?: any;
40+
}
41+
interface B {
42+
}
43+
declare function isA(x: any): x is A;
44+
declare function isB(x: any): x is B;
45+
declare let myIsA: typeof isA;
46+
declare let myIsAny: typeof isB;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates04.ts(25,1): error TS2322: Type '(x: any) => x is E' is not assignable to type '(x: any) => x is number'.
2+
Type predicate 'x is E' is not assignable to 'x is number'.
3+
Type 'E' is not assignable to type 'number'.
4+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates04.ts(26,1): error TS2322: Type '(x: any) => x is number' is not assignable to type '(x: any) => x is E'.
5+
Type predicate 'x is number' is not assignable to 'x is E'.
6+
Type 'number' is not assignable to type 'E'.
7+
8+
9+
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatForSignaturesWithTypePredicates04.ts (2 errors) ====
10+
11+
enum E {
12+
A = 1,
13+
B = 2,
14+
C = 3,
15+
}
10000 16+
17+
function isA(x: any): x is number {
18+
return typeof x === "number";
19+
}
20+
21+
function isB(x: any): x is E {
22+
switch (x) {
23+
case E.A:
24+
case E.B:
25+
case E.C:
26+
return true;
27+
}
28+
return false;
29+
}
30+
31+
let myIsA = isA;
32+
let myIsB = isB;
33+
34+
myIsA = myIsB;
35+
~~~~~
36+
!!! error TS2322: Type '(x: any) => x is E' is not assignable to type '(x: any) => x is number'.
37+
!!! error TS2322: Type predicate 'x is E' is not assignable to 'x is number'.
38+
!!! error TS2322: Type 'E' is not assignable to type 'number'.
39+
myIsB = myIsA;
40+
~~~~~
41+
!!! error TS2322: Type '(x: any) => x is number' is not assignable to type '(x: any) => x is E'.
42+
!!! error TS2322: Type predicate 'x is number' is not assignable to 'x is E'.
43+
!!! error TS2322: Type 'number' is not assignable to type 'E'.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//// [assignmentCompatForSignaturesWithTypePredicates04.ts]
2+
3+
enum E {
4+
A = 1,
5+
B = 2,
6+
C = 3,
7+
}
8+
9+
function isA(x: any): x is number {
10+
return typeof x === "number";
11+
}
12+
13+
function isB(x: any): x is E {
14+
switch (x) {
15+
case E.A:
16+
case E.B:
17+
case E.C:
18+
return true;
19+
}
20+
return false;
21+
}
22+
23+
let myIsA = isA;
24+
let myIsB = isB;
25+
26+
myIsA = myIsB;
27+
myIsB = myIsA;
28+
29+
//// [assignmentCompatForSignaturesWithTypePredicates04.js]
30+
var E;
31+
(function (E) {
32+
E[E["A"] = 1] = "A";
33+
E[E["B"] = 2] = "B";
34+
E[E["C"] = 3] = "C";
35+
})(E || (E = {}));
36+
function isA(x) {
37+
return typeof x === "number";
38+
}
39+
function isB(x) {
40+
switch (x) {
41+
case E.A:
42+
case E.B:
43+
case E.C:
44+
return true;
45+
}
46+
return false;
47+
}
48+
var myIsA = isA;
49+
var myIsB = isB;
50+
myIsA = myIsB;
51+
myIsB = myIsA;
52+
53+
54+
//// [assignmentCompatForSignaturesWithTypePredicates04.d.ts]
55+
declare enum E {
56+
A = 1,
57+
B = 2,
58+
C = 3,
59+
}
60+
declare function isA(x: any): x is number;
61+
declare function isB(x: any): x is E;
62+
declare let myIsA: typeof isA;
63+
declare let myIsB: typeof isB;

0 commit comments

Comments
 (0)
0