microsoft / microsoft/monaco-editor

Monaco-editor-core cannot be compiled: Cannot redeclare block-scoped variable 'MonacoEnvironment'.

Open
#4,049 4 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug editor-core
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: latest
  • OS Version: any OS

Steps to Reproduce:

  1. Set up a project like https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-webpack-typescript
  2. Perform type check by tsc or fork-ts-checker-webpack-plugin.

Expected behavior
Compile successfully

Actual behavior
Cannot compile due to the error

node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts:12:9 - error TS2451: Cannot redeclare block-scoped variable 'MonacoEnvironment'.

12     let MonacoEnvironment: Environment | undefined;
           ~~~~~~~~~~~~~~~~~

  node_modules/monaco-editor/monaco.d.ts:11:13
    11 declare let MonacoEnvironment: monaco.Environment | undefined;
                   ~~~~~~~~~~~~~~~~~
    'MonacoEnvironment' was also declared here.

node_modules/monaco-editor/monaco.d.ts:11:13 - error TS2451: Cannot redeclare block-scoped variable 'MonacoEnvironment'.

11 declare let MonacoEnvironment: monaco.Environment | undefined;
               ~~~~~~~~~~~~~~~~~

  node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts:12:9
    12     let MonacoEnvironment: Environment | undefined;
               ~~~~~~~~~~~~~~~~~
    'MonacoEnvironment' was also declared here.


Found 2 errors.

The reason behind this is you are coping declaration file in monaco.d.ts to editor.api.d.ts in https://github.com/microsoft/vscode/blob/c248f9ec0cf272351175ccf934054b18ffbf18c6/build/gulpfile.editor.js#L303-L320

Please fix it so we can compile the apps that use monaco-editor-core

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.