diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b839dafd3e8..8d134ac6839 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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]; diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt new file mode 100644 index 00000000000..080aca5a7ac --- /dev/null +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt @@ -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'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.js b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.js new file mode 100644 index 00000000000..0a1109a14f7 --- /dev/null +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.js @@ -0,0 +1,7 @@ +//// [assignmentRestElementWithErrorSourceType.ts] +var tuple: [string, number]; +[...c] = tupel; // intentionally misspelled + +//// [assignmentRestElementWithErrorSourceType.js] +var tuple; +c = tupel.slice(0); // intentionally misspelled diff --git a/tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts b/tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts new file mode 100644 index 00000000000..21b437be48e --- /dev/null +++ b/tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts @@ -0,0 +1,2 @@ +var tuple: [string, number]; +[...c] = tupel; // intentionally misspelled \ No newline at end of file