Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9412,7 +9412,10 @@ module ts {
}

if (isArrayLikeType(inputType)) {
return getIndexTypeOfType(inputType, IndexKind.Number);
let indexType = getIndexTypeOfType(inputType, IndexKind.Number);
if (indexType) {
return indexType;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What were we getting before? unknownType?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined. causing a crash later on.

}
}

error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
Expand Down
4 changes: 3 additions & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,7 @@ module ts {

case SyntaxKind.SemicolonToken:
return containingNodeKind === SyntaxKind.PropertySignature &&
previousToken.parent && previousToken.parent.parent &&
(previousToken.parent.parent.kind === SyntaxKind.InterfaceDeclaration || // interface a { f; |
previousToken.parent.parent.kind === SyntaxKind.TypeLiteral); // let x : { a; |

Expand All @@ -3124,7 +3125,8 @@ module ts {
case SyntaxKind.DotDotDotToken:
return containingNodeKind === SyntaxKind.Parameter ||
containingNodeKind === SyntaxKind.Constructor ||
(previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [ ...z|
(previousToken.parent && previousToken.parent.parent &&
previousToken.parent.parent.kind === SyntaxKind.ArrayBindingPattern); // var [ ...z|

case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
Expand Down
5 changes: 4 additions & 1 deletion tests/baselines/reference/assignmentLHSIsValue.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(3
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,1): error TS2461: Type 'any' is not an array type.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
Expand All @@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: Invalid left-hand side of assignment expression.


==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ====
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
// expected error for all the LHS of assignments
var value;

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

// array literals
['', ''] = value;
~~~~~~~~
!!! error TS2461: Type 'any' is not an array type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird

  1. It should be okay with any, you shouldn't get an error from this, should you?
  2. I'm pretty sure that shouldn't even be a valid LHS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have two others errors after that:
!!! error TS2364: Invalid left-hand side of assignment expression.
!!! error TS2364: Invalid left-hand side of assignment expression.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it's been a long day.

~~
!!! error TS2364: Invalid left-hand side of assignment expression.
~~
Expand Down
6 changes: 6 additions & 0 deletions tests/cases/fourslash/completionAfterDotDotDot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference path='fourslash.ts'/>

////.../**/

goTo.marker();
verify.not.completionListIsEmpty();
9 changes: 9 additions & 0 deletions tests/cases/fourslash/completionInIncompleteCallExpression.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts'/>

////var array = [1, 2, 4]
////function a4(x, y, z) { }
////a4(...<crash>/**/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think <crash> was meant to be included in this test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still crashed for me with it :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the issue, it is to indicate that this will be a crash. Though it is still a nice test case to have :)



goTo.marker();
verify.not.completionListIsEmpty();