Microsoft/monaco-editor

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

Open

#1306 opened on Feb 7, 2019

View on GitHub
 (2 comments) (1 reaction) (1 assignee)JavaScript (14,836 stars) (1,283 forks)batch import
bughelp wantedtypescripttypescript-multifile

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