fix: disable false "Cannot find module" diagnostics in editor (#588)

* fix: disable false "Cannot find module" diagnostics in editor

Monaco's TypeScript worker runs in isolation without filesystem access,
so it cannot resolve imports to project files that aren't open as editor
models. This produces false "Cannot find module" diagnostics for every
import in TS/JS files, which is misleading noise.

Disable semantic validation for both TypeScript and JavaScript defaults.
Syntax highlighting and basic validation remain intact.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(monaco): surgically disable TS diagnostics 2307, 2792 instead of all semantic validation

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
This commit is contained in:
Ramzi
2026-04-13 11:04:13 -07:00
committed by GitHub
co-authored by Claude Opus 4.6 Jinjing
parent e7f6344e89
commit c9ca2baa77
+13
View File
@@ -31,6 +31,19 @@ globalThis.MonacoEnvironment = {
}
}
// Why: Monaco's built-in TypeScript worker runs in isolation without filesystem
// access, so it cannot resolve imports to project files that aren't open as
// editor models. This produces false "Cannot find module" diagnostics for every
// import statement. Ignoring specific TS diagnostic codes (e.g., 2307, 2792)
// removes this noise while keeping type checking, auto-complete, and basic
// validation fully functional for local symbols.
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
diagnosticCodesToIgnore: [2307, 2792]
})
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
diagnosticCodesToIgnore: [2307, 2792]
})
// Configure Monaco to use the locally bundled editor instead of CDN
loader.config({ monaco })