Skip to content
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

"Uncaught Error: Could not find source file" when using setCompilerOptions on monaco instance #75

Closed
nickjanssen opened this issue May 6, 2020 · 4 comments

Comments

@nickjanssen
Copy link

nickjanssen commented May 6, 2020

Hello! Thank you for making this library, it's so much better than other monaco editors out there.

Describe the bug
It appears that doing anything with the monaco instance results in Uncaught Error: Could not find source file errors.

To Reproduce

Add the following to your code:

monaco.init().then(monaco => {
  monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
    noLib: true
  });
});

Also be sure to use language="javascript"

Here's a minimally reproducable example:
https://codesandbox.io/s/patient-sky-uykvg?file=/src/App.js

Note that these errors don't show in the Codesandbox console for some reason, you have to actually open your Chrome console to see them.

@suren-atoyan
Copy link
Owner

Hello @nickjanssen. Thank you for feedback.

I've found this issue. I assume it's related to the original library.

@jannisch
Copy link

jannisch commented Jun 29, 2020

I also experienced this issue but was able to fix it by including the default options. Try this:

let options = monaco.languages.typescript.javascriptDefaults.getCompilerOptions()
options.noLib = true // example change
monaco.languages.typescript.javascriptDefaults.setCompilerOptions(options)

@suren-atoyan
Copy link
Owner

Hello @nickjanssen, sorry for the late answer

It was related to the monaco-editor version. Check new versions it's fixed.

@VitalickS
Copy link

I also experienced this issue but was able to fix it by including the default options. Try this:

let options = monaco.languages.typescript.javascriptDefaults.getCompilerOptions()
options.noLib = true // example change
monaco.languages.typescript.javascriptDefaults.setCompilerOptions(options)

its because you need set allowNonTsExtensions to true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants