Microsoft/monaco-editor
在 GitHub 查看Monaco fail to resolve ts/js modules with reserved (or non-ASCII) URI characters in model name.
Open
#1,306 建立於 2019年2月7日
bughelp wantedtypescripttypescript-multifile
描述
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:
- Load Monaco editor
- 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
});
- 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.

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