Skip to content

Commit 5e09e86

Browse files
authored
return early from fixUnreachableCode if syntactic errors exists (#47463)
1 parent e9453f4 commit 5e09e86

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/services/codefixes/fixUnreachableCode.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace ts.codefix {
55
registerCodeFix({
66
errorCodes,
77
getCodeActions(context) {
8+
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
9+
if (syntacticDiagnostics.length) return;
810
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
911
return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unreachable_code, fixId, Diagnostics.Remove_all_unreachable_code)];
1012
},

0 commit comments

Comments
 (0)