Fix crash in rest element destructuring

This commit is contained in:
Jason Freeman 2015-04-10 16:54:17 -07:00
parent 5bfbcdcd25
commit e6ffb33adf
4 changed files with 21 additions and 1 deletions

View File

@ -7633,7 +7633,7 @@ module ts {
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType;
let elements = node.elements;
for (let i = 0; i < elements.length; i++) {
let e = elements[i];

View File

@ -0,0 +1,11 @@
tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,5): error TS2304: Cannot find name 'c'.
tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS2304: Cannot find name 'tupel'.
==== tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts (2 errors) ====
var tuple: [string, number];
[...c] = tupel; // intentionally misspelled
~
!!! error TS2304: Cannot find name 'c'.
~~~~~
!!! error TS2304: Cannot find name 'tupel'.

View File

@ -0,0 +1,7 @@
//// [assignmentRestElementWithErrorSourceType.ts]
var tuple: [string, number];
[...c] = tupel; // intentionally misspelled
//// [assignmentRestElementWithErrorSourceType.js]
var tuple;
c = tupel.slice(0); // intentionally misspelled

View File

@ -0,0 +1,2 @@
var tuple: [string, number];
[...c] = tupel; // intentionally misspelled