diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts
index 7b97161aabe..b6212e2a2d2 100644
--- a/src/services/outliningElementsCollector.ts
+++ b/src/services/outliningElementsCollector.ts
@@ -182,7 +182,8 @@ namespace ts.OutliningElementsCollector {
return spanForNode(n.parent);
}
else if (tryStatement.finallyBlock === n) {
- return spanForNode(findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile)!);
+ const node = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
+ if (node) return spanForNode(node);
}
// falls through
default:
diff --git a/tests/cases/fourslash/correuptedTryExpressionsDontCrashGettingOutlineSpans.ts b/tests/cases/fourslash/correuptedTryExpressionsDontCrashGettingOutlineSpans.ts
new file mode 100644
index 00000000000..f03cad9d765
--- /dev/null
+++ b/tests/cases/fourslash/correuptedTryExpressionsDontCrashGettingOutlineSpans.ts
@@ -0,0 +1,13 @@
+///
+
+// #33102
+
+//// try[| {
+//// var x = [
+//// {% try[||] %}|][|{% except %}|]
+//// ]
+//// } catch (e)[| {
+////
+//// }|]
+
+verify.outliningSpansInCurrentFile(test.ranges());
diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts
index 692e47a1421..6e76b6fc0a9 100644
--- a/tests/cases/fourslash/fourslash.ts
+++ b/tests/cases/fourslash/fourslash.ts
@@ -433,6 +433,7 @@ declare namespace FourSlashInterface {
printNavigationBar(): void;
printNavigationItems(searchValue?: string): void;
printScriptLexicalStructureItems(): void;
+ printOutliningSpans(): void;
printReferences(): void;
printContext(): void;
}
@@ -775,4 +776,4 @@ declare namespace completion {
export const statementKeywordsWithTypes: ReadonlyArray;
export const statementKeywords: ReadonlyArray;
export const statementInJsKeywords: ReadonlyArray;
-}
\ No newline at end of file
+}