-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Semantic validation across multiple editor instances #2976
Comments
Are there any known workarounds for this issue while the bug is not fixed? Besides that, with some pointers in the right direction, I might be able to submit a PR for this :) |
All the typescript related code is here: https://github.com/microsoft/monaco-editor/tree/main/src/language/typescript Unfortunately, I don't know that code very well. |
Having the same issue while having an editor in the UI and trying to validate the syntax of the code in a completely separate model. |
I solved this problem with the setting - I marked the modules as isolated in the compiler options:
But I'm not sure, if this applies to all issues here. |
There is a new But the option isn't present in Monaco's Plus, when setting it manually it doesn't address the issue: monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
allowJs: true,
checkJs: true,
allowNonTsExtensions: true,
isolatedModules: true,
moduleDetection: 'force'
}) |
TLDR: Use I've been digging into the code in Monaco and it seems the compiler options are all passed through, so whether or not the I also found that when setting the compiler option So trying to figure out why that is, I dug deeper into the language service and I found that it actually uses numeric constants for these options, not strings! So the solution is to set Here's the relevant code in the language service that gave me the hint that internally it uses numeric constants: moduleDetection: {
dependencies: ["module", "target"],
computeValue: (compilerOptions) => {
return compilerOptions.moduleDetection || (computedOptions.module.computeValue(compilerOptions) === 100 /* Node16 */ || computedOptions.module.computeValue(compilerOptions) === 199 /* NodeNext */ ? 3 /* Force */ : 2 /* Auto */);
}
}, It seems as if all other options have Here's another monaco-editor/src/language/typescript/monaco.contribution.ts Lines 50 to 53 in b31d22b
|
I'm facing the same problem in my app where two editors are visible at the same time but should not share any context. Setting
and the other editor can access said global. how to make two full isolated and standalone versions of monaco? Is there maybe a way to set different workers for different editors? |
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
Actual Behavior
Both editor instances prompt "Cannot redeclare block-scoped variable 'abc'." error.
Expected Behavior
No error prompt. It should be possible to use variables with the same name in two different files.
Additional Context
No response
The text was updated successfully, but these errors were encountered: