mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
accept new baselines
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts(3,3): error TS2339: Property 'nonExist' does not exist on type 'object'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAccessProperty.ts (1 errors) ====
|
||||
var a: object;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'nonExist' does not exist on type 'object'.
|
||||
|
||||
10
tests/baselines/reference/nonPrimitiveAccessProperty.js
Normal file
10
tests/baselines/reference/nonPrimitiveAccessProperty.js
Normal file
@@ -0,0 +1,10 @@
|
||||
//// [nonPrimitiveAccessProperty.ts]
|
||||
var a: object;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
|
||||
|
||||
//// [nonPrimitiveAccessProperty.js]
|
||||
var a;
|
||||
a.toString();
|
||||
a.nonExist(); // error
|
||||
@@ -41,4 +41,12 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts(17,1): err
|
||||
s = a; // expect error
|
||||
~
|
||||
!!! error TS2322: Type 'object' is not assignable to type 'string'.
|
||||
|
||||
var numObj: Number = 123;
|
||||
var boolObj: Boolean = true;
|
||||
var strObj: String = "string";
|
||||
|
||||
a = numObj; // ok
|
||||
a = boolObj; // ok
|
||||
a = strObj; // ok
|
||||
|
||||
@@ -16,6 +16,14 @@ a = s; // expect error
|
||||
n = a; // expect error
|
||||
b = a; // expect error
|
||||
s = a; // expect error
|
||||
|
||||
var numObj: Number = 123;
|
||||
var boolObj: Boolean = true;
|
||||
var strObj: String = "string";
|
||||
|
||||
a = numObj; // ok
|
||||
a = boolObj; // ok
|
||||
a = strObj; // ok
|
||||
|
||||
|
||||
//// [nonPrimitiveAssignError.js]
|
||||
@@ -33,3 +41,9 @@ a = s; // expect error
|
||||
n = a; // expect error
|
||||
b = a; // expect error
|
||||
s = a; // expect error
|
||||
var numObj = 123;
|
||||
var boolObj = true;
|
||||
var strObj = "string";
|
||||
a = numObj; // ok
|
||||
a = boolObj; // ok
|
||||
a = strObj; // ok
|
||||
|
||||
@@ -2,9 +2,11 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(7,17): error
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(8,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(14,7): error TS2345: Argument of type '123' is not assignable to parameter of type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(21,8): error TS2344: Type 'number' does not satisfy the constraint 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(22,8): error TS2344: Type 'string' does not satisfy the constraint 'object'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (4 errors) ====
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts (6 errors) ====
|
||||
function generic<T>(t: T) {}
|
||||
var a = {};
|
||||
var b = "42";
|
||||
@@ -28,4 +30,15 @@ tests/cases/conformance/types/nonPrimitive/nonPrimitiveInGeneric.ts(15,7): error
|
||||
bound(b); // expect error
|
||||
~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object'.
|
||||
|
||||
function bound2<T extends object>() {}
|
||||
|
||||
bound2<{}>();
|
||||
bound2<Object>();
|
||||
bound2<number>(); // expect error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'number' does not satisfy the constraint 'object'.
|
||||
bound2<string>(); // expect error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'object'.
|
||||
|
||||
@@ -14,6 +14,13 @@ bound({});
|
||||
bound(a);
|
||||
bound(123); // expect error
|
||||
bound(b); // expect error
|
||||
|
||||
function bound2<T extends object>() {}
|
||||
|
||||
bound2<{}>();
|
||||
bound2<Object>();
|
||||
bound2<number>(); // expect error
|
||||
bound2<string>(); // expect error
|
||||
|
||||
|
||||
//// [nonPrimitiveInGeneric.js]
|
||||
@@ -29,3 +36,8 @@ bound({});
|
||||
bound(a);
|
||||
bound(123); // expect error
|
||||
bound(b); // expect error
|
||||
function bound2() { }
|
||||
bound2();
|
||||
bound2();
|
||||
bound2(); // expect error
|
||||
bound2(); // expect error
|
||||
|
||||
35
tests/baselines/reference/nonPrimitiveNarrow.errors.txt
Normal file
35
tests/baselines/reference/nonPrimitiveNarrow.errors.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(9,5): error TS2322: Type '123' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(13,7): error TS2339: Property 'toFixed' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts(21,6): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts (3 errors) ====
|
||||
class Narrow {
|
||||
narrowed: boolean
|
||||
}
|
||||
|
||||
var a: object
|
||||
|
||||
if (a instanceof Narrow) {
|
||||
a.narrowed; // ok
|
||||
a = 123; // error
|
||||
~
|
||||
!!! error TS2322: Type '123' is not assignable to type 'object'.
|
||||
}
|
||||
|
||||
if (typeof a === 'number') {
|
||||
a.toFixed(); // error, never
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'toFixed' does not exist on type 'never'.
|
||||
}
|
||||
|
||||
var b: object | null
|
||||
|
||||
if (typeof b === 'object') {
|
||||
b.toString(); // ok, object | null
|
||||
} else {
|
||||
b.toString(); // error, never
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
}
|
||||
|
||||
46
tests/baselines/reference/nonPrimitiveNarrow.js
Normal file
46
tests/baselines/reference/nonPrimitiveNarrow.js
Normal file
@@ -0,0 +1,46 @@
|
||||
//// [nonPrimitiveNarrow.ts]
|
||||
class Narrow {
|
||||
narrowed: boolean
|
||||
}
|
||||
|
||||
var a: object
|
||||
|
||||
if (a instanceof Narrow) {
|
||||
a.narrowed; // ok
|
||||
a = 123; // error
|
||||
}
|
||||
|
||||
if (typeof a === 'number') {
|
||||
a.toFixed(); // error, never
|
||||
}
|
||||
|
||||
var b: object | null
|
||||
|
||||
if (typeof b === 'object') {
|
||||
b.toString(); // ok, object | null
|
||||
} else {
|
||||
b.toString(); // error, never
|
||||
}
|
||||
|
||||
|
||||
//// [nonPrimitiveNarrow.js]
|
||||
var Narrow = (function () {
|
||||
function Narrow() {
|
||||
}
|
||||
return Narrow;
|
||||
}());
|
||||
var a;
|
||||
if (a instanceof Narrow) {
|
||||
a.narrowed; // ok
|
||||
a = 123; // error
|
||||
}
|
||||
if (typeof a === 'number') {
|
||||
a.toFixed(); // error, never
|
||||
}
|
||||
var b;
|
||||
if (typeof b === 'object') {
|
||||
b.toString(); // ok, object | null
|
||||
}
|
||||
else {
|
||||
b.toString(); // error, never
|
||||
}
|
||||
117
tests/baselines/reference/nonPrimitiveStrictNull.errors.txt
Normal file
117
tests/baselines/reference/nonPrimitiveStrictNull.errors.txt
Normal file
@@ -0,0 +1,117 @@
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(7,1): error TS2454: Variable 'a' is used before being assigned.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(8,1): error TS2322: Type 'undefined' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(9,1): error TS2322: Type 'null' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(10,1): error TS2322: Type 'object | null' is not assignable to type 'object'.
|
||||
Type 'null' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(11,1): error TS2322: Type 'object | undefined' is not assignable to type 'object'.
|
||||
Type 'undefined' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(12,1): error TS2322: Type 'object | null | undefined' is not assignable to type 'object'.
|
||||
Type 'undefined' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(18,7): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(22,5): error TS2322: Type 'object | null' is not assignable to type 'object'.
|
||||
Type 'null' is not assignable to type 'object'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(27,5): error TS2531: Object is possibly 'null'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,5): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(29,7): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,5): error TS2533: Object is possibly 'null' or 'undefined'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(33,7): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,5): error TS2531: Object is possibly 'null'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(39,7): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(41,5): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,5): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(45,7): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts(47,5): error TS2531: Object is possibly 'null'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveStrictNull.ts (19 errors) ====
|
||||
|
||||
var a: object
|
||||
declare var b: object | null
|
||||
declare var c: object | undefined
|
||||
declare var d: object | null | undefined
|
||||
var e: object | null
|
||||
a.toString; // error
|
||||
~
|
||||
!!! error TS2454: Variable 'a' is used before being assigned.
|
||||
a = undefined; // error
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
|
||||
a = null; // error
|
||||
~
|
||||
!!! error TS2322: Type 'null' is not assignable to type 'object'.
|
||||
a = b; // error
|
||||
~
|
||||
!!! error TS2322: Type 'object | null' is not assignable to type 'object'.
|
||||
!!! error TS2322: Type 'null' is not assignable to type 'object'.
|
||||
a = c; // error
|
||||
~
|
||||
!!! error TS2322: Type 'object | undefined' is not assignable to type 'object'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
|
||||
a = d; // error
|
||||
~
|
||||
!!! error TS2322: Type 'object | null | undefined' is not assignable to type 'object'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'object'.
|
||||
|
||||
e = a; // ok
|
||||
a = e; // ok
|
||||
|
||||
if (typeof b !== 'object') {
|
||||
b.toString(); // error, never
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
}
|
||||
|
||||
if (typeof b === 'object') {
|
||||
a = b; // error, b is not narrowed
|
||||
~
|
||||
!!! error TS2322: Type 'object | null' is not assignable to type 'object'.
|
||||
!!! error TS2322: Type 'null' is not assignable to type 'object'.
|
||||
}
|
||||
|
||||
if (typeof d === 'object') {
|
||||
b = d; // ok
|
||||
d.toString(); // error, object | null
|
||||
~
|
||||
!!! error TS2531: Object is possibly 'null'.
|
||||
} else {
|
||||
d.toString(); // error, undefined
|
||||
~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
}
|
||||
|
||||
if (d == null) {
|
||||
d.toString(); // error, undefined | null
|
||||
~
|
||||
!!! error TS2533: Object is possibly 'null' or 'undefined'.
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
} else {
|
||||
d.toString(); // object
|
||||
}
|
||||
|
||||
if (d === null) {
|
||||
d.toString(); // error, null
|
||||
~
|
||||
!!! error TS2531: Object is possibly 'null'.
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
} else {
|
||||
d.toString(); // error, object | undefined
|
||||
~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
}
|
||||
|
||||
if (typeof d === 'undefined') {
|
||||
d.toString(); // error, undefined
|
||||
~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
} else {
|
||||
d.toString(); // error, object | null
|
||||
~
|
||||
!!! error TS2531: Object is possibly 'null'.
|
||||
}
|
||||
|
||||
93
tests/baselines/reference/nonPrimitiveStrictNull.js
Normal file
93
tests/baselines/reference/nonPrimitiveStrictNull.js
Normal file
@@ -0,0 +1,93 @@
|
||||
//// [nonPrimitiveStrictNull.ts]
|
||||
|
||||
var a: object
|
||||
declare var b: object | null
|
||||
declare var c: object | undefined
|
||||
declare var d: object | null | undefined
|
||||
var e: object | null
|
||||
a.toString; // error
|
||||
a = undefined; // error
|
||||
a = null; // error
|
||||
a = b; // error
|
||||
a = c; // error
|
||||
a = d; // error
|
||||
|
||||
e = a; // ok
|
||||
a = e; // ok
|
||||
|
||||
if (typeof b !== 'object') {
|
||||
b.toString(); // error, never
|
||||
}
|
||||
|
||||
if (typeof b === 'object') {
|
||||
a = b; // error, b is not narrowed
|
||||
}
|
||||
|
||||
if (typeof d === 'object') {
|
||||
b = d; // ok
|
||||
d.toString(); // error, object | null
|
||||
} else {
|
||||
d.toString(); // error, undefined
|
||||
}
|
||||
|
||||
if (d == null) {
|
||||
d.toString(); // error, undefined | null
|
||||
} else {
|
||||
d.toString(); // object
|
||||
}
|
||||
|
||||
if (d === null) {
|
||||
d.toString(); // error, null
|
||||
} else {
|
||||
d.toString(); // error, object | undefined
|
||||
}
|
||||
|
||||
if (typeof d === 'undefined') {
|
||||
d.toString(); // error, undefined
|
||||
} else {
|
||||
d.toString(); // error, object | null
|
||||
}
|
||||
|
||||
|
||||
//// [nonPrimitiveStrictNull.js]
|
||||
var a;
|
||||
var e;
|
||||
a.toString; // error
|
||||
a = undefined; // error
|
||||
a = null; // error
|
||||
a = b; // error
|
||||
a = c; // error
|
||||
a = d; // error
|
||||
e = a; // ok
|
||||
a = e; // ok
|
||||
if (typeof b !== 'object') {
|
||||
b.toString(); // error, never
|
||||
}
|
||||
if (typeof b === 'object') {
|
||||
a = b; // error, b is not narrowed
|
||||
}
|
||||
if (typeof d === 'object') {
|
||||
b = d; // ok
|
||||
d.toString(); // error, object | null
|
||||
}
|
||||
else {
|
||||
d.toString(); // error, undefined
|
||||
}
|
||||
if (d == null) {
|
||||
d.toString(); // error, undefined | null
|
||||
}
|
||||
else {
|
||||
d.toString(); // object
|
||||
}
|
||||
if (d === null) {
|
||||
d.toString(); // error, null
|
||||
}
|
||||
else {
|
||||
d.toString(); // error, object | undefined
|
||||
}
|
||||
if (typeof d === 'undefined') {
|
||||
d.toString(); // error, undefined
|
||||
}
|
||||
else {
|
||||
d.toString(); // error, object | null
|
||||
}
|
||||
@@ -16,7 +16,7 @@ if (typeof a === 'number') {
|
||||
var b: object | null
|
||||
|
||||
if (typeof b === 'object') {
|
||||
b.toString(); // error, object | null
|
||||
b.toString(); // ok, object | null
|
||||
} else {
|
||||
b.toString(); // error, never
|
||||
}
|
||||
|
||||
@@ -25,24 +25,25 @@ if (typeof b === 'object') {
|
||||
|
||||
if (typeof d === 'object') {
|
||||
b = d; // ok
|
||||
d.toString(); // error, object | null
|
||||
} else {
|
||||
d; // undefined
|
||||
d.toString(); // error, undefined
|
||||
}
|
||||
|
||||
if (d == null) {
|
||||
d; // null | undefined
|
||||
d.toString(); // error, undefined | null
|
||||
} else {
|
||||
d.toString(); // object
|
||||
}
|
||||
|
||||
if (d === null) {
|
||||
d; // null
|
||||
d.toString(); // error, null
|
||||
} else {
|
||||
d.toString(); // error, object | undefined
|
||||
}
|
||||
|
||||
if (typeof d === 'undefined') {
|
||||
d; // undefined
|
||||
d.toString(); // error, undefined
|
||||
} else {
|
||||
d.toString(); // error, object | null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user