diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index 53181994b..dc6b61f81 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -84,16 +84,13 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider { const checkers = [lang.getSuggestionDiagnostics, lang.getSemanticDiagnostics]; for (const checker of checkers) { - if (!cancellationToken) { - diagnostics.push(...checker.call(lang, tsDoc.filePath)); - continue; - } - - // wait a bit so the event loop can check for cancellation - // or let completion go first - await new Promise((resolve) => setTimeout(resolve, 10)); - if (cancellationToken.isCancellationRequested) { - return []; + if (cancellationToken) { + // wait a bit so the event loop can check for cancellation + // or let completion go first + await new Promise((resolve) => setTimeout(resolve, 10)); + if (cancellationToken.isCancellationRequested) { + return []; + } } diagnostics.push(...checker.call(lang, tsDoc.filePath)); }