microsoft / microsoft/monaco-editor

Monaco fail to resolve ts/js modules with reserved (or non-ASCII) URI characters in model name.

Open
#1,306 2 comments 1 reaction 1 assignee View on GitHub

@alexdima is already working on this.

Since Dec 13, 2019.

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

Description

monaco-editor version: 0.15.6
Browser: Chrome Version 72.0.3626.81 (Official Build) (64-bit)
OS: Ubuntu 16.04

Steps or JS usage snippet reproducing the issue:

  1. Load Monaco editor
  2. Set default options
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
    allowNonTsExtensions: true,
    allowJs: true,
    isolatedModules: true,
    outDir: "dummy"
});
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
    noSemanticValidation: false,
    noSyntacticValidation: false
});
  1. Create three models:
  • a model that name contains only unreserved URI characters (e.g. test.ts).
  • a model that name contains at least one character that should be URL-encoded: (e.g. test(1).ts).
  • a model with script that imports two models above (e.g. main.ts).
monaco.editor.createModel([
    "export let x = 10;"
].join('\n'), "typescript", monaco.Uri.file("test.ts"));

monaco.editor.createModel([
    "export let x = 10;"
].join('\n'), "typescript", monaco.Uri.file("test(1).ts"));

monaco.editor.createModel([
    "import { x } from './test(1)'",
    "import { y } from './test'",
    "let z = x + 10 + y;"
].join('\n'), "typescript", monaco.Uri.file("main.ts"));

Expected result
Both dependencies are successfully resolved.

Actual result
The dependency that have a not unreserved URI characters can't be found by Monaco. The type information is not available for the dependency.
selection_022

If one replaces module name in import statement with encoded one, the module is successfully resolved and all works fine.
selection_023

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.