mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-30 15:15:38 -05:00
At '.' in object literal, don't close the object (#27850)
* At '.' in object literal, don't close the object * Include diagnostics test
This commit is contained in:
@@ -1482,7 +1482,15 @@ namespace ts {
|
||||
// which would be a candidate for improved error reporting.
|
||||
return token() === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName();
|
||||
switch (token()) {
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.AsteriskToken:
|
||||
case SyntaxKind.DotDotDotToken:
|
||||
case SyntaxKind.DotToken: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`)
|
||||
return true;
|
||||
default:
|
||||
return isLiteralPropertyName();
|
||||
}
|
||||
case ParsingContext.RestProperties:
|
||||
return isLiteralPropertyName();
|
||||
case ParsingContext.ObjectBindingElements:
|
||||
|
||||
@@ -596,8 +596,7 @@ namespace ts {
|
||||
{
|
||||
compilerOptions: {
|
||||
target: undefined,
|
||||
module: ModuleKind.ESNext,
|
||||
types: []
|
||||
module: ModuleKind.ESNext
|
||||
},
|
||||
hasParseErrors: true
|
||||
}
|
||||
|
||||
10
tests/cases/fourslash/completionsDotInObjectLiteral.ts
Normal file
10
tests/cases/fourslash/completionsDotInObjectLiteral.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////const o = {
|
||||
//// a: 1,
|
||||
//// [|.|]/**/
|
||||
////[|}|];
|
||||
|
||||
verify.getSyntacticDiagnostics(test.ranges().map((range): FourSlashInterface.Diagnostic =>
|
||||
({ code: 1003, message: "Identifier expected.", range })));
|
||||
verify.completions({ marker: "", exact: undefined });
|
||||
Reference in New Issue
Block a user