Skip to content

Commit fe50957

Browse files
committed
Merge pull request microsoft#2756 from Microsoft/completionFixes
Completion fixes
2 parents cca29a5 + fe75002 commit fe50957

5 files changed

Lines changed: 26 additions & 3 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));

src/services/services.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3109,6 +3109,7 @@ module ts {
31093109

31103110
case SyntaxKind.SemicolonToken:
31113111
return containingNodeKind === SyntaxKind.PropertySignature &&
3112+
previousToken.parent && previousToken.parent.parent &&
31123113
(previousToken.parent.parent.kind === SyntaxKind.InterfaceDeclaration || // interface a { f; |
31133114
previousToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; |
31143115

@@ -3124,7 +3125,8 @@ module ts {
31243125
case SyntaxKind.DotDotDotToken:
31253126
return containingNodeKind === SyntaxKind.Parameter ||
31263127
containingNodeKind === SyntaxKind.Constructor ||
3127-
(previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [ ...z|
3128+
(previousToken.parent && previousToken.parent.parent &&
3129+
previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [ ...z|
31283130

31293131
case SyntaxKind.PublicKeyword:
31303132
case SyntaxKind.PrivateKeyword:

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////.../**/
4+
5+
goTo.marker();
6+
verify.not.completionListIsEmpty();
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)