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

both ngx-monaco-editor and monaco-editor define MonacoEnvironment #91

Open
thomasvt opened this issue Mar 15, 2022 · 6 comments
Open

both ngx-monaco-editor and monaco-editor define MonacoEnvironment #91

thomasvt opened this issue Mar 15, 2022 · 6 comments

Comments

@thomasvt
Copy link

Hello,

In old major versions, a global variable "MonacoEnvironment" was defined by the monaco-editor package only. But since a few major versions, @materia-ui/ngx-monaco-editor also defines it, causing compile errors when your code imports both:

eg. I need MarkerSeverity and Range from the monaco-editor package because I do things that seem not to be possible through the @materia-ui package. (create squible errors, insert code-snippets)

To get the error, simply create the minimal example like on your github .md and then import something from monaco_editor:

import { MarkerSeverity, Range } from 'monaco-editor';

Error TS2451: Cannot redeclare block-scoped variable 'MonacoEnvironment'.

  • definition 1: node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts:12:9
  • definition 2: node_modules/@materia-ui/ngx-monaco-editor/lib/interfaces/monaco.d.ts:6:13

When I manually remove the declaration in node_modules/@materia-ui/... everything works, but of course i cannot do this on our automated build agents.

Is there some way to fix this, please?

@kprasad99
Copy link

I'm also getting same error

@nikhilnxvverma1
Copy link

Also getting the same error

@rbelando
Copy link

Same here :D

@ivan-kzn
Copy link

ivan-kzn commented Feb 17, 2023

Have anyone found workaround for this?

@thomasvt
Copy link
Author

Hi, it's been a while but I remember coming to the conclusion that this repo is dead and we had to fix our problem.

So, I just copied the code of the materia package to my app (as if we wrote it ourselves) and fixed the issue as I explained in my OP.

You could also try using only the original one https://microsoft.github.io/monaco-editor/ I don't remember what the difference is or why we ended up using the Materia fork, but I guess we had our reasons.

@ivan-kzn
Copy link

thanks @thomasvt

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

5 participants