Compiler test case for usage of contextual rest parameter

This commit is contained in:
Sheetal Nandi 2014-10-08 12:31:03 -07:00
parent b405045106
commit 966e697f2a
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,16 @@
tests/cases/compiler/contextuallyTypingRestParameters.ts(3,9): error TS2323: Type 'string[]' is not assignable to type 'string'.
tests/cases/compiler/contextuallyTypingRestParameters.ts(5,9): error TS2323: Type 'string[]' is not assignable to type 'string'.
==== tests/cases/compiler/contextuallyTypingRestParameters.ts (2 errors) ====
var x: (...y: string[]) => void = function (.../*3*/y) {
var t = y;
var x2: string = t; // This should be error
~~
!!! error TS2323: Type 'string[]' is not assignable to type 'string'.
var x3: string[] = t; // No error
var y2: string = y; // This should be error
~~
!!! error TS2323: Type 'string[]' is not assignable to type 'string'.
var y3: string[] = y; // No error
};

View File

@ -0,0 +1,21 @@
//// [contextuallyTypingRestParameters.ts]
var x: (...y: string[]) => void = function (.../*3*/y) {
var t = y;
var x2: string = t; // This should be error
var x3: string[] = t; // No error
var y2: string = y; // This should be error
var y3: string[] = y; // No error
};
//// [contextuallyTypingRestParameters.js]
var x = function () {
var y = [];
for (var _i = 0; _i < arguments.length; _i++) {
y[_i - 0] = arguments[_i];
}
var t = y;
var x2 = t; // This should be error
var x3 = t; // No error
var y2 = y; // This should be error
var y3 = y; // No error
};

View File

@ -0,0 +1,7 @@
var x: (...y: string[]) => void = function (.../*3*/y) {
var t = y;
var x2: string = t; // This should be error
var x3: string[] = t; // No error
var y2: string = y; // This should be error
var y3: string[] = y; // No error
};