Skip to content

Commit fe75002

Browse files
committed
Fix microsoft#2724: ensure checkIteratedTypeOrElementType returns a type
1 parent 4e42054 commit fe75002

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9412,7 +9412,10 @@ module ts {
94129412
}
94139413

94149414
if (isArrayLikeType(inputType)) {
9415-
return getIndexTypeOfType(inputType, IndexKind.Number);
9415+
let indexType = getIndexTypeOfType(inputType, IndexKind.Number);
9416+
if (indexType) {
9417+
return indexType;
9418+
}
94169419
}
94179420

94189421
error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));

tests/baselines/reference/assignmentLHSIsValue.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(3
1414
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
1515
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
1616
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
17+
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,1): error TS2461: Type 'any' is not an array type.
1718
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
1819
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
1920
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
@@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
3839
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.
3940

4041

41-
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ====
42+
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
4243
// expected error for all the LHS of assignments
4344
var value;
4445

@@ -109,6 +110,8 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
109110

110111
// array literals
111112
['', ''] = value;
113+
~~~~~~~~
114+
!!! error TS2461: Type 'any' is not an array type.
112115
~~
113116
!!! error TS2364: Invalid left-hand side of assignment expression.
114117
~~
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////var array = [1, 2, 4]
4+
////function a4(x, y, z) { }
5+
////a4(...<crash>/**/
6+
7+
8+
goTo.marker();
9+
verify.not.completionListIsEmpty();

0 commit comments

Comments
 (0)