monaco-react
monaco-react copied to clipboard
`getLanguageId()` is not a function
Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
- Go to the callback function of the
onMount. - do either
editor.getModel().getLanguageId()ormonaco.editor.getModels()[0].getLanguageId(). - 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/reacttogether. And monaco-langaugeclient is callingmodel.getLanguageId().
Expected behavior
Expected getLanguageId() available.
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ITextModel.html#getLanguageId
Any luck with this? I'm having a similar issue
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