diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts
index 8060145ef026f..5a9948cd35f72 100644
--- a/src/services/formatting/formatting.ts
+++ b/src/services/formatting/formatting.ts
@@ -445,7 +445,7 @@ namespace ts.formatting {
undefined;
if (tokenInfo) {
- const parent = findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode) || previousParent!;
+ const parent = findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)?.parent || previousParent!;
processPair(
tokenInfo,
sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line,
diff --git a/tests/cases/fourslash/server/formatOnTypeOpenCurlyWithBraceCompletion.ts b/tests/cases/fourslash/formatOnTypeOpenCurlyWithBraceCompletion.ts
similarity index 79%
rename from tests/cases/fourslash/server/formatOnTypeOpenCurlyWithBraceCompletion.ts
rename to tests/cases/fourslash/formatOnTypeOpenCurlyWithBraceCompletion.ts
index dceda9e98fcb0..b303b1ea62d6d 100644
--- a/tests/cases/fourslash/server/formatOnTypeOpenCurlyWithBraceCompletion.ts
+++ b/tests/cases/fourslash/formatOnTypeOpenCurlyWithBraceCompletion.ts
@@ -1,4 +1,4 @@
-///
+///
//// if (foo) {
//// if (bar) {/**/}