microsoft / microsoft/monaco-editor

[Bug] Semantic validation across multiple editor instances

Open
#2,976 7 comments 6 reactions 2 assignees View on GitHub

@alexdima is already working on this.

Since Feb 16, 2022.

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

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
  noSyntaxValidation: false,
  noSemanticValidation: false
})

monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
  allowJs: true,
  checkJs: true,
  allowNonTsExtensions: true
})

monaco.editor.create(document.getElementById('container1'), {
  model: monaco.editor.createModel('const abc = 1', 'javascript', monaco.Uri.parse('file:///a.js'))
})

monaco.editor.create(document.getElementById('container2'), {
  model: monaco.editor.createModel('const abc = 2', 'javascript', monaco.Uri.parse('file:///b.js'))
})

<div id="container1" style="height: 50%"></div>
<div id="container2" style="height: 50%"></div>
Actual Behavior

Both editor instances prompt "Cannot redeclare block-scoped variable 'abc'." error.

Expected Behavior

No error prompt. It should be possible to use variables with the same name in two different files.

Additional Context

No response

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.