microsoft / microsoft/monaco-editor
monaco-typescript not picking up configured modules from addExtraLib
Open
Nobody has claimed this yet.
feature-request
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.10.1
Browser: Chrome and Edge tried, presumably any
OS: Windows 10 tried, presumably any
Steps or JS usage snippet reproducing the issue:
- Into the Monaco playground, type the following:
const externalDTS = `export declare function next() : string`;
const externalDTSFilename = 'external.d.ts';
const useExtraLib = true;
if (useExtraLib) {
monaco.languages.typescript.typescriptDefaults.addExtraLib(externalDTS, externalDTSFilename);
}
var jsCode = `import * as x from "external";\nconst tt : string = x.next();`;
if (!useExtraLib) {
var extModel = monaco.editor.createModel(externalDTS, "typescript",monaco.Uri.parse("file:///" + externalDTSFilename));
}
monaco.editor.create(document.getElementById("container"), {
model: monaco.editor.createModel(jsCode,"typescript",monaco.Uri.parse("file:///main.tsx")),
});
- Run it.
- Note that "external" is marked as an error - the module is not found.
- Flip
useExtraLibtofalseto seed the editor with the type definition file in another file/model instead of viaaddExtraLib. - Run it.
- Note that "external" now resolves correctly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in the Monaco playground using the provided addExtraLib and createModel snippets, then compare module resolution with and without the extra library. The work is done when the external import resolves through addExtraLib as it does when the declaration file is seeded as another model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100