mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Compiler test case for usage of contextual rest parameter
This commit is contained in:
parent
b405045106
commit
966e697f2a
@ -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
|
||||
};
|
||||
@ -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
|
||||
};
|
||||
7
tests/cases/compiler/contextuallyTypingRestParameters.ts
Normal file
7
tests/cases/compiler/contextuallyTypingRestParameters.ts
Normal 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
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user