Open dipamsen opened 3 years ago
I think you have to include allowJs
and checkJs
in the compiler options for this to work properly, otherwise it seems to fall back to TypeScript mode even if your model is JavaScript. But I agree that the experience could be improved here.
// compiler options
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES6,
allowJs: true,
checkJs: true,
allowNonTsExtensions: true
});
@spahnke thanks... exactly what I was looking for 👍
@alexdima can we set this as default for js?
I am using the following configuration:
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false
});
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES6,
allowJs: true,
checkJs: true,
allowNonTsExtensions: true
});
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource);
I then use JSDoc to reference the type and it works for intellisense, but if I break the type requirement then I don't see the red mark that I expect. Is it supposed to work now?
Please let me know if I should provide a playground with an example.
I am using the following configuration:
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({ noSemanticValidation: false, noSyntaxValidation: false }); monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES6, allowJs: true, checkJs: true, allowNonTsExtensions: true }); monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource);
I then use JSDoc to reference the type and it works for intellisense, but if I break the type requirement then I don't see the red mark that I expect. Is it supposed to work now?
Please let me know if I should provide a playground with an example.
it's working for monaco-editor@0.47.0
monaco-editor version: Latest Browser: Chrome OS: Windows Playground code that reproduces the issue: Extending Language Services > Configuring JavaScript Defaults
(Set
noSemanticValidation
tofalse
on line 8)In this editor, the language is set to
javascript
and semantic validation is turned on for type checking. (Equivalent to// @ts-check
in VSCode).Since the compiler is TypeScript, it allows any valid TypeScript, which can be invalid JavaScript.
Take the following code block for example:
Expected Behaviour (from VSCode)
Actual Behaviour (in playground)