From 584e923f4239b1b79d2ee1d1c0ad79b4edb847b0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 28 Jun 2018 16:00:51 -0700 Subject: [PATCH] Accepted baselines. --- ...ckJsdocTypeTagOnObjectProperty2.errors.txt | 4 +-- ...oratedErrorsOnNullableTargets01.errors.txt | 31 +++++++++++++++++++ .../elaboratedErrorsOnNullableTargets01.js | 13 ++++++++ ...laboratedErrorsOnNullableTargets01.symbols | 19 ++++++++++++ .../elaboratedErrorsOnNullableTargets01.types | 23 ++++++++++++++ ...ExtendsObjectIntersectionErrors.errors.txt | 4 +-- ...intersectionWithUnionConstraint.errors.txt | 4 +-- .../reference/mappedTypeErrors.errors.txt | 12 +++---- .../reference/objectCreate-errors.errors.txt | 24 +++++++------- .../typeFromJSConstructor.errors.txt | 4 +-- .../typeFromJSInitializer.errors.txt | 4 +-- 11 files changed, 114 insertions(+), 28 deletions(-) create mode 100644 tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt create mode 100644 tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js create mode 100644 tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols create mode 100644 tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt index 926de030117..48559d79cb1 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string | undefined'. tests/cases/conformance/jsdoc/0.js(7,3): error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/jsdoc/0.js(11,3): error TS2322: Type '(n1: number) => string' is not assignable to type '(arg0: number) => number'. @@ -16,7 +16,7 @@ tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type '"0"' /** @type {string|undefined} */ bar: 42, ~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. /** @type {function(number): number} */ method1(n1) { ~~~~~~~ diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt new file mode 100644 index 00000000000..e2a3ebbf1db --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.errors.txt @@ -0,0 +1,31 @@ +tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(4,1): error TS2322: Type '{ foo: { bar: number; }; }' is not assignable to type '{ foo: { bar: string; }; }'. + Types of property 'foo' are incompatible. + Type '{ bar: number; }' is not assignable to type '{ bar: string; }'. + Types of property 'bar' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts(6,1): error TS2322: Type '{ foo: { bar: string; }; }' is not assignable to type '{ foo: { bar: number; }; }'. + Types of property 'foo' are incompatible. + Type '{ bar: string; }' is not assignable to type '{ bar: number; }'. + Types of property 'bar' are incompatible. + Type 'string' is not assignable to type 'number'. + + +==== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts (2 errors) ==== + export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; + export declare let y: { foo: { bar: number | undefined } }; + + x = y; + ~ +!!! error TS2322: Type '{ foo: { bar: number; }; }' is not assignable to type '{ foo: { bar: string; }; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '{ bar: number; }' is not assignable to type '{ bar: string; }'. +!!! error TS2322: Types of property 'bar' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + y = x; + ~ +!!! error TS2322: Type '{ foo: { bar: string; }; }' is not assignable to type '{ foo: { bar: number; }; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type '{ bar: string; }' is not assignable to type '{ bar: number; }'. +!!! error TS2322: Types of property 'bar' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js new file mode 100644 index 00000000000..5c5f8700218 --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.js @@ -0,0 +1,13 @@ +//// [elaboratedErrorsOnNullableTargets01.ts] +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +export declare let y: { foo: { bar: number | undefined } }; + +x = y; + +y = x; + +//// [elaboratedErrorsOnNullableTargets01.js] +"use strict"; +exports.__esModule = true; +exports.x = exports.y; +exports.y = exports.x; diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols new file mode 100644 index 00000000000..4f218b2e28f --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts === +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) +>foo : Symbol(foo, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 30)) +>bar : Symbol(bar, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 37)) + +export declare let y: { foo: { bar: number | undefined } }; +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) +>foo : Symbol(foo, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 23)) +>bar : Symbol(bar, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 30)) + +x = y; +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) + +y = x; +>y : Symbol(y, Decl(elaboratedErrorsOnNullableTargets01.ts, 1, 18)) +>x : Symbol(x, Decl(elaboratedErrorsOnNullableTargets01.ts, 0, 18)) + diff --git a/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types new file mode 100644 index 00000000000..e580b90a732 --- /dev/null +++ b/tests/baselines/reference/elaboratedErrorsOnNullableTargets01.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/elaboratedErrorsOnNullableTargets01.ts === +export declare let x: null | { foo: { bar: string | null } | undefined } | undefined; +>x : { foo: { bar: string; }; } +>null : null +>foo : { bar: string; } +>bar : string +>null : null + +export declare let y: { foo: { bar: number | undefined } }; +>y : { foo: { bar: number; }; } +>foo : { bar: number; } +>bar : number + +x = y; +>x = y : { foo: { bar: number; }; } +>x : { foo: { bar: string; }; } +>y : { foo: { bar: number; }; } + +y = x; +>y = x : { foo: { bar: string; }; } +>y : { foo: { bar: number; }; } +>x : { foo: { bar: string; }; } + diff --git a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt index 31fe5c67d85..87faadeb4a6 100644 --- a/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt +++ b/tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt @@ -39,7 +39,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(35,29): error TS2411: Property 'a' of type '"hello"' is not assignable to string index type 'number'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(39,11): error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(40,11): error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. Types of property 'a' are incompatible. Type 'string' is not assignable to type 'number'. @@ -154,7 +154,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI ~~~ !!! error TS2430: Interface 'I20' incorrectly extends interface 'Partial'. !!! error TS2430: Types of property 'a' are incompatible. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Type 'string' is not assignable to type 'number | undefined'. interface I21 extends Readonly { a: string } ~~~ !!! error TS2430: Interface 'I21' incorrectly extends interface 'Readonly'. diff --git a/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt b/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt index 2ff5947af2b..9bdfc6f30f9 100644 --- a/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt +++ b/tests/baselines/reference/intersectionWithUnionConstraint.errors.txt @@ -12,7 +12,7 @@ tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(10 Type 'T & U' is not assignable to type 'number'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(11,9): error TS2322: Type 'T & U' is not assignable to type 'number | undefined'. Type 'string | undefined' is not assignable to type 'number | undefined'. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number | undefined'. Type 'T & U' is not assignable to type 'number'. tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(12,9): error TS2322: Type 'T & U' is not assignable to type 'null | undefined'. Type 'string | undefined' is not assignable to type 'null | undefined'. @@ -50,7 +50,7 @@ tests/cases/conformance/types/intersection/intersectionWithUnionConstraint.ts(12 ~~ !!! error TS2322: Type 'T & U' is not assignable to type 'number | undefined'. !!! error TS2322: Type 'string | undefined' is not assignable to type 'number | undefined'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. !!! error TS2322: Type 'T & U' is not assignable to type 'number'. let y6: null | undefined = x; // Error ~~ diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index fe29215d140..f78c32531a4 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -39,13 +39,13 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,14): error TS2345: Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(128,5): error TS2322: Type '{ a: string; }' is not assignable to type 'T2'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(129,5): error TS2322: Type '{ a: string; }' is not assignable to type 'Partial'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(130,5): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,16): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'. Type 'T' is not assignable to type 'symbol'. tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: Type 'P' cannot be used to index type 'T'. @@ -242,17 +242,17 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(136,21): error TS2536: ~~ !!! error TS2322: Type '{ a: string; }' is not assignable to type 'T2'. !!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. let x2: Partial = { a: 'no' }; // Error ~~ !!! error TS2322: Type '{ a: string; }' is not assignable to type 'Partial'. !!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error ~~ !!! error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: any; a?: number | undefined; }'. !!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. // Repro from #13044 diff --git a/tests/baselines/reference/objectCreate-errors.errors.txt b/tests/baselines/reference/objectCreate-errors.errors.txt index 200a9bc4560..12f62cc4d2c 100644 --- a/tests/baselines/reference/objectCreate-errors.errors.txt +++ b/tests/baselines/reference/objectCreate-errors.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/objectCreate-errors.ts(1,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object'. -tests/cases/compiler/objectCreate-errors.ts(2,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object'. -tests/cases/compiler/objectCreate-errors.ts(3,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. +tests/cases/compiler/objectCreate-errors.ts(1,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(2,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(3,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. tests/cases/compiler/objectCreate-errors.ts(4,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(7,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object'. -tests/cases/compiler/objectCreate-errors.ts(8,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object'. -tests/cases/compiler/objectCreate-errors.ts(9,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. +tests/cases/compiler/objectCreate-errors.ts(7,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(8,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(9,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. tests/cases/compiler/objectCreate-errors.ts(10,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. ==== tests/cases/compiler/objectCreate-errors.ts (8 errors) ==== var e1 = Object.create(1); // Error ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. var e2 = Object.create("string"); // Error ~~~~~~~~ -!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. var e3 = Object.create(false); // Error ~~~~~ -!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. var e4 = Object.create(undefined); // Error ~~~~~~~~~ !!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. @@ -25,13 +25,13 @@ tests/cases/compiler/objectCreate-errors.ts(10,24): error TS2345: Argument of ty var e5 = Object.create(1, {}); // Error ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. var e6 = Object.create("string", {}); // Error ~~~~~~~~ -!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. var e7 = Object.create(false, {}); // Error ~~~~~ -!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. var e8 = Object.create(undefined, {}); // Error ~~~~~~~~~ !!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. \ No newline at end of file diff --git a/tests/baselines/reference/typeFromJSConstructor.errors.txt b/tests/baselines/reference/typeFromJSConstructor.errors.txt index 09de1bad812..ffcf5393f51 100644 --- a/tests/baselines/reference/typeFromJSConstructor.errors.txt +++ b/tests/baselines/reference/typeFromJSConstructor.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/salsa/a.js(10,5): error TS7008: Member 'twices' implicit tests/cases/conformance/salsa/a.js(14,5): error TS2322: Type '"hi"' is not assignable to type 'number'. tests/cases/conformance/salsa/a.js(21,5): error TS2322: Type 'false' is not assignable to type 'number'. tests/cases/conformance/salsa/a.js(24,5): error TS2322: Type 'null' is not assignable to type 'string | undefined'. -tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'false' is not assignable to type 'string | undefined'. tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null'. @@ -41,7 +41,7 @@ tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null !!! error TS2322: Type 'null' is not assignable to type 'string | undefined'. this.twice = false // error ~~~~~~~~~~ -!!! error TS2322: Type 'false' is not assignable to type 'string'. +!!! error TS2322: Type 'false' is not assignable to type 'string | undefined'. this.twices.push(1) // error: Object is possibly null ~~~~~~~~~~~ !!! error TS2531: Object is possibly 'null'. diff --git a/tests/baselines/reference/typeFromJSInitializer.errors.txt b/tests/baselines/reference/typeFromJSInitializer.errors.txt index 8e9bb5f3e3d..08d66a2a9f3 100644 --- a/tests/baselines/reference/typeFromJSInitializer.errors.txt +++ b/tests/baselines/reference/typeFromJSInitializer.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/salsa/a.js(4,5): error TS7008: Member 'unknowable' impli tests/cases/conformance/salsa/a.js(5,5): error TS7008: Member 'empty' implicitly has an 'any[]' type. tests/cases/conformance/salsa/a.js(25,12): error TS7006: Parameter 'a' implicitly has an 'any' type. tests/cases/conformance/salsa/a.js(25,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. -tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type '"error"' is not assignable to type 'number'. +tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type '"error"' is not assignable to type 'number | undefined'. ==== tests/cases/conformance/salsa/a.js (6 errors) ==== @@ -55,7 +55,7 @@ tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type '"error"' is not as b = undefined b = 'error' ~ -!!! error TS2322: Type '"error"' is not assignable to type 'number'. +!!! error TS2322: Type '"error"' is not assignable to type 'number | undefined'. // l should be any[] l.push(1)