monaco-react icon indicating copy to clipboard operation
monaco-react copied to clipboard

`getLanguageId()` is not a function

Open haow-abc opened this issue 3 years ago • 2 comments

Describe the bug A clear and concise description of what the bug is. image

To Reproduce

Steps to reproduce the behavior:

  1. Go to the callback function of the onMount.
  2. do either editor.getModel().getLanguageId() or monaco.editor.getModels()[0].getLanguageId().
  3. You will see the error.
  • And I see there is a getLanguageIdentifier() function available here, but this is not what I want. I am using monaco-languageclient with @monaco-editor/react together. And monaco-langaugeclient is calling model.getLanguageId().

Expected behavior Expected getLanguageId() available. https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ITextModel.html#getLanguageId

haow-abc avatar Feb 14 '22 20:02 haow-abc

Any luck with this? I'm having a similar issue

dkattan avatar Mar 07 '22 19:03 dkattan

Turns out I hadn't actually updated monaco-editor. I had to run yarn upgrade monaco-editor --latest and make sure there were no missing peer dependencies. Once monaco-editor upgraded to version 32.1 I had another issue where _contribution.js needed a loader. To fix this I had to add

module.exports = {
  transpileDependencies: [
    'monaco-editor',
  ],
}

to my vue.config.js file.

I know this is a React issue but hopefully this saves someone time.

This helped with the transpile issue: https://stackoverflow.com/questions/70538511/you-may-need-an-additional-loader-to-handle-the-result-of-these-loaders-upgradi

dkattan avatar Mar 07 '22 20:03 dkattan