Skip to content

Commit c19221c

Browse files
accept new baselines
1 parent 2fb51e7 commit c19221c

12 files changed

+365
-6
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'.
2+
3+
4+
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ====
5+
var a: object;
6+
a.toString();
7+
a.nonExist(); // error
8+
~~~~~~~~
9+
!!! error TS2339: Property 'nonExist' does not exist on type 'object'.
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [nonPrimitiveAccessProperty.ts]
2+
var a: object;
3+
a.toString();
4+
a.nonExist(); // error
5+
6+
7+
//// [nonPrimitiveAccessProperty.js]
8+
var a;
9+
a.toString();
10+
a.nonExist(); // error

tests/baselines/reference/nonPrimitiveAssignError.errors.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): err
4141
s = a; // expect error
4242
~
4343
!!! error TS2322: Type 'object' is not assignable to type 'string'.
44+
45+
var numObj: Number = 123;
46+
var boolObj: Boolean = true;
47+
var strObj: String = "string";
48+
49+
a = numObj; // ok
50+
a = boolObj; // ok
51+
a = strObj; // ok
4452

tests/baselines/reference/nonPrimitiveAssignError.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ a = s; // expect error
1616
n = a; // expect error
1717
b = a; // expect error
1818
s = a; // expect error
19+
20+
var numObj: Number = 123;
21+
var boolObj: Boolean = true;
22+
var strObj: String = "string";
23+
24+
a = numObj; // ok
25+
a = boolObj; // ok
26+
a = strObj; // ok
1927

2028

2129
//// [nonPrimitiveAssignError.js]
@@ -33,3 +41,9 @@ a = s; // expect error
3341
n = a; // expect error
3442
b = a; // expect error
3543
s = a; // expect error
44+
var numObj = 123;
45+
var boolObj = true;
46+
var strObj = "string";
47+
a = numObj; // ok
48+
a = boolObj; // ok
49+
a = strObj; // ok

tests/baselines/reference/nonPrimitiveInGeneric.errors.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(7,17): error
22
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(8,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
33
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'.
44
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
5+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(21,8): error TS2344: Type 'number' does not satisfy the constraint 'object'.
6+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error TS2344: Type 'string' does not satisfy the constraint 'object'.
57

68

7-
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (4 errors) ====
9+
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (6 errors) ====
810
function generic<T>(t: T) {}
911
var a = {};
1012
var b = "42";
@@ -28,4 +30,15 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error
2830
bound(b); // expect error
2931
~
3032
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
33+
34+
function bound2<T extends object>() {}
35+
36+
bound2<{}>();
37+
bound2<Object>();
38+
bound2<number>(); // expect error
39+
~~~~~~
40+
!!! error TS2344: Type 'number' does not satisfy the constraint 'object'.
41+
bound2<string>(); // expect error
42+
~~~~~~
43+
!!! error TS2344: Type 'string' does not satisfy the constraint 'object'.
3144

tests/baselines/reference/nonPrimitiveInGeneric.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ bound({});
1414
bound(a);
1515
bound(123); // expect error
1616
bound(b); // expect error
17+
18+
function bound2<T extends object>() {}
19+
20+
bound2<{}>();
21+
bound2<Object>();
22+
bound2<number>(); // expect error
23+
bound2<string>(); // expect error
1724

1825

1926
//// [nonPrimitiveInGeneric.js]
@@ -29,3 +36,8 @@ bound({});
2936
bound(a);
3037
bound(123); // expect error
3138
bound(b); // expect error
39+
function bound2() { }
40+
bound2();
41+
bound2();
42+
bound2(); // expect error
43+
bound2(); // expect error
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(9,5): error TS2322: Type '123' is not assignable to type 'object'.
2+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(13,7): error TS2339: Property 'toFixed' does not exist on type 'never'.
3+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(21,6): error TS2339: Property 'toString' does not exist on type 'never'.
4+
5+
6+
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts (3 errors) ====
7+
class Narrow {
8+
narrowed: boolean
9+
}
10+
11+
var a: object
12+
13+
if (a instanceof Narrow) {
14+
a.narrowed; // ok
15+
a = 123; // error
16+
~
17+
!!! error TS2322: Type '123' is not assignable to type 'object'.
18+
}
19+
20+
if (typeof a === 'number') {
21+
a.toFixed(); // error, never
22+
~~~~~~~
23+
!!! error TS2339: Property 'toFixed' does not exist on type 'never'.
24+
}
25+
26+
var b: object | null
27+
28+
if (typeof b === 'object') {
29+
b.toString(); // ok, object | null
30+
} else {
31+
b.toString(); // error, never
32+
~~~~~~~~
33+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
34+
}
35+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [nonPrimitiveNarrow.ts]
2+
class Narrow {
3+
narrowed: boolean
4+
}
5+
6+
var a: object
7+
8+
if (a instanceof Narrow) {
9+
a.narrowed; // ok
10+
a = 123; // error
11+
}
12+
13+
if (typeof a === 'number') {
14+
a.toFixed(); // error, never
15+
}
16+
17+
var b: object | null
18+
19+
if (typeof b === 'object') {
20+
b.toString(); // ok, object | null
21+
} else {
22+
b.toString(); // error, never
23+
}
24+
25+
26+
//// [nonPrimitiveNarrow.js]
27+
var Narrow = (function () {
28+
function Narrow() {
29+
}
30+
return Narrow;
31+
}());
32+
var a;
33+
if (a instanceof Narrow) {
34+
a.narrowed; // ok
35+
a = 123; // error
36+
}
37+
if (typeof a === 'number') {
38+
a.toFixed(); // error, never
39+
}
40+
var b;
41+
if (typeof b === 'object') {
42+
b.toString(); // ok, object | null
43+
}
44+
else {
45+
b.toString(); // error, never
46+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned.
2+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'.
3+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'.
4+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'.
5+
Type 'null' is not assignable to type 'object'.
6+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'.
7+
Type 'undefined' is not assignable to type 'object'.
8+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'.
9+
Type 'undefined' is not assignable to type 'object'.
10+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'.
11+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'.
12+
Type 'null' is not assignable to type 'object'.
13+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'.
14+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'.
15+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,7): error TS2339: Property 'toString' does not exist on type 'never'.
16+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'.
17+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,7): error TS2339: Property 'toString' does not exist on type 'never'.
18+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'.
19+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,7): error TS2339: Property 'toString' does not exist on type 'never'.
20+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'.
21+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'.
22+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'.
23+
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'.
24+
25+
26+
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (19 errors) ====
27+
28+
var a: object
29+
declare var b: object | null
30+
declare var c: object | undefined
31+
declare var d: object | null | undefined
32+
var e: object | null
33+
a.toString; // error
34+
~
35+
!!! error TS2454: Variable 'a' is used before being assigned.
36+
a = undefined; // error
37+
~
38+
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
39+
a = null; // error
40+
~
41+
!!! error TS2322: Type 'null' is not assignable to type 'object'.
42+
a = b; // error
43+
~
44+
!!! error TS2322: Type 'object | null' is not assignable to type 'object'.
45+
!!! error TS2322: Type 'null' is not assignable to type 'object'.
46+
a = c; // error
47+
~
48+
!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'.
49+
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
50+
a = d; // error
51+
~
52+
!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'.
53+
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
54+
55+
e = a; // ok
56+
a = e; // ok
57+
58+
if (typeof b !== 'object') {
59+
b.toString(); // error, never
60+
~~~~~~~~
61+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
62+
}
63+
64+
if (typeof b === 'object') {
65+
a = b; // error, b is not narrowed
66+
~
67+
!!! error TS2322: Type 'object | null' is not assignable to type 'object'.
68+
!!! error TS2322: Type 'null' is not assignable to type 'object'.
69+
}
70+
71+
if (typeof d === 'object') {
72+
b = d; // ok
73+
d.toString(); // error, object | null
74+
~
75+
!!! error TS2531: Object is possibly 'null'.
76+
} else {
77+
d.toString(); // error, undefined
78+
~
79+
!!! error TS2532: Object is possibly 'undefined'.
80+
~~~~~~~~
81+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
82+
}
83+
84+
if (d == null) {
85+
d.toString(); // error, undefined | null
86+
~
87+
!!! error TS2533: Object is possibly 'null' or 'undefined'.
88+
~~~~~~~~
89+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
90+
} else {
91+
d.toString(); // object
92+
}
93+
94+
if (d === null) {
95+
d.toString(); // error, null
96+
~
97+
!!! error TS2531: Object is possibly 'null'.
98+
~~~~~~~~
99+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
100+
} else {
101+
d.toString(); // error, object | undefined
102+
~
103+
!!! error TS2532: Object is possibly 'undefined'.
104+
}
105+
106+
if (typeof d === 'undefined') {
107+
d.toString(); // error, undefined
108+
~
109+
!!! error TS2532: Object is possibly 'undefined'.
110+
~~~~~~~~
111+
!!! error TS2339: Property 'toString' does not exist on type 'never'.
112+
} else {
113+
d.toString(); // error, object | null
114+
~
115+
!!! error TS2531: Object is possibly 'null'.
116+
}
117+

0 commit comments

Comments
 (0)