@@ -104,7 +104,10 @@ namespace ts.formatting {
104104 export function formatOnOpeningCurly ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
105105 const openingCurly = findImmediatelyPrecedingTokenOfKind ( position , SyntaxKind . OpenBraceToken , sourceFile ) ;
106106 const curlyBraceRange = openingCurly && openingCurly . parent ;
107- return formatOutermostNodeWithinListLevel ( curlyBraceRange , sourceFile , options , rulesProvider , FormattingRequestKind . FormatOnOpeningCurlyBrace ) ;
107+ const nextToken = curlyBraceRange && findNextToken ( openingCurly , curlyBraceRange ) ;
108+ return nextToken && nextToken . kind === SyntaxKind . CloseBraceToken ?
109+ formatOutermostNodeWithinListLevel ( curlyBraceRange , sourceFile , options , rulesProvider , FormattingRequestKind . FormatOnOpeningCurlyBrace ) :
110+ [ ] ;
108111 }
109112
110113 export function formatOnClosingCurly ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
@@ -130,8 +133,8 @@ namespace ts.formatting {
130133 }
131134
132135 /**
133- * Validating `expectedLastToken ` ensures the token was typed in the context we expect (eg: not a comment).
134- * @param expectedLastToken The last token constituting the desired parent node.
136+ * Validating `expectedTokenKind ` ensures the token was typed in the context we expect (eg: not a comment).
137+ * @param expectedTokenKind The kind of the last token constituting the desired parent node.
135138 */
136139 function findImmediatelyPrecedingTokenOfKind ( end : number , expectedTokenKind : SyntaxKind , sourceFile : SourceFile ) : Node | undefined {
137140 const precedingToken = findPrecedingToken ( end , sourceFile ) ;
@@ -142,8 +145,8 @@ namespace ts.formatting {
142145 }
143146
144147 /**
145- * Finds and formats the highest node enclosing `position ` whose end does not exceed the given position
146- * and is at the same list level as the token at `position `.
148+ * Finds and formats the highest node enclosing `node ` whose end does not exceed the `node.end`
149+ * and is at the same list level as the token at `node `.
147150 *
148151 * Consider typing the following
149152 * ```
0 commit comments