At '.' in array literal, don't close the array (#28120)

This commit is contained in:
Andy 2018-10-25 12:25:33 -07:00 committed by GitHub
parent 539b9a6d50
commit efc831e0ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -1518,8 +1518,10 @@ namespace ts {
case ParsingContext.TypeParameters:
return isIdentifier();
case ParsingContext.ArrayLiteralMembers:
if (token() === SyntaxKind.CommaToken) {
return true;
switch (token()) {
case SyntaxKind.CommaToken:
case SyntaxKind.DotToken: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`)
return true;
}
// falls through
case ParsingContext.ArgumentExpressions:

View file

@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////const o = { x: [[|.|][||]/**/
const [r0, r1] = test.ranges();
verify.getSyntacticDiagnostics([
{ code: 1109, message: "Expression expected.", range: r0 },
{ code: 1003, message: "Identifier expected.", range: r1 },
]);
verify.completions({ marker: "", exact: undefined });