From 8eacd41ab0300259c4837702e0dfddf22bd22e8a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 15 Oct 2015 09:52:31 -0700 Subject: [PATCH] Add tests and accept baselines --- .../baselines/reference/assignmentCompat1.errors.txt | 10 +++++++++- tests/baselines/reference/assignmentCompat1.js | 5 +++++ tests/baselines/reference/indexTypeCheck.errors.txt | 5 ++++- tests/baselines/reference/intTypeCheck.errors.txt | 12 +++++++++++- tests/cases/compiler/assignmentCompat1.ts | 3 +++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/assignmentCompat1.errors.txt b/tests/baselines/reference/assignmentCompat1.errors.txt index edb8d28eecc..93afdbe1bcb 100644 --- a/tests/baselines/reference/assignmentCompat1.errors.txt +++ b/tests/baselines/reference/assignmentCompat1.errors.txt @@ -2,9 +2,11 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st Property 'one' is missing in type '{ [index: string]: any; }'. tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. Property 'one' is missing in type '{ [index: number]: any; }'. +tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. + Index signature is missing in type 'String'. -==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ==== +==== tests/cases/compiler/assignmentCompat1.ts (3 errors) ==== var x = { one: 1 }; var y: { [index: string]: any }; var z: { [index: number]: any }; @@ -18,4 +20,10 @@ tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: nu !!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. !!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'. z = x; // Ok because index signature type is any + y = "foo"; // Error + ~ +!!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. +!!! error TS2322: Index signature is missing in type 'String'. + z = "foo"; // Error + \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompat1.js b/tests/baselines/reference/assignmentCompat1.js index 740a44cced4..a873c24c567 100644 --- a/tests/baselines/reference/assignmentCompat1.js +++ b/tests/baselines/reference/assignmentCompat1.js @@ -6,6 +6,9 @@ x = y; // Error y = x; // Ok because index signature type is any x = z; // Error z = x; // Ok because index signature type is any +y = "foo"; // Error +z = "foo"; // Error + //// [assignmentCompat1.js] @@ -16,3 +19,5 @@ x = y; // Error y = x; // Ok because index signature type is any x = z; // Error z = x; // Ok because index signature type is any +y = "foo"; // Error +z = "foo"; // Error diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 2ea5a2f413a..06b844f8321 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -1,13 +1,14 @@ tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation. tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. +tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ==== +==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ==== interface Red { [n:number]; // ok ~~~~~~~~~~~ @@ -36,6 +37,8 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression interface Green { [n:number]: Orange; // error + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'. [s:string]: Yellow; // ok } diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 7f1cc88e2a2..e48d1b1dc73 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -30,6 +30,8 @@ tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. + Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -66,12 +68,14 @@ tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. +tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. + Index signature is missing in type 'Boolean'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. -==== tests/cases/compiler/intTypeCheck.ts (61 errors) ==== +==== tests/cases/compiler/intTypeCheck.ts (63 errors) ==== interface i1 { //Property Signatures p; @@ -280,6 +284,9 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit //var obj40: i4 = function foo() { }; var obj41: i4 = anyVar; var obj42: i4 = new anyVar; + ~~~~~ +!!! error TS2322: Type 'boolean' is not assignable to type 'i4'. +!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ @@ -402,6 +409,9 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit //var obj84: i8 = function foo() { }; var obj85: i8 = anyVar; var obj86: i8 = new anyVar; + ~~~~~ +!!! error TS2322: Type 'boolean' is not assignable to type 'i8'. +!!! error TS2322: Index signature is missing in type 'Boolean'. ~ !!! error TS1109: Expression expected. ~~ diff --git a/tests/cases/compiler/assignmentCompat1.ts b/tests/cases/compiler/assignmentCompat1.ts index b37a11b20d9..54dc91adab0 100644 --- a/tests/cases/compiler/assignmentCompat1.ts +++ b/tests/cases/compiler/assignmentCompat1.ts @@ -5,3 +5,6 @@ x = y; // Error y = x; // Ok because index signature type is any x = z; // Error z = x; // Ok because index signature type is any +y = "foo"; // Error +z = "foo"; // Error +