FR: Detect when addExtraLib is done processing / Permit bulk add/delete extra lib operations
See original GitHub issuemonaco-editor version: 0.15.6
Adding a lot of DTS files for use in JavaScript/TypeScript frequently takes several seconds for the TypeScript compiler to process. As best I can tell, there is no way to programmatically determine when the compiler has processed the extra files and is “stable” again.
The idea is that, when calling monaco.languages.typescript.LanguageServiceDefaults.addExtraLib
with large DTS files, it would be helpful to show the user an indeterminate progress bar to make it clear that autocompletions are not available presently. Notifying the program that processing is complete could be accomplished via an event, a promise returned from addExtraLib
, or an optional callback to addExtraLib
.
Note, if addExtraLib
is called multiple times in quick succession, we would want to know when the TypeScript compiler has finished processing all of the DTS files, not only/just a single DTS file.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
I’ll try to create a PR with this features this week. As far as I know, there’s no existing issue for this.
From my experience, the reason for the delay is not the processing delay, but rather inefficient handling of extraLibs in monaco-typescript. As it is right now, in the official monaco-typescript release, whenever addExtraLib is called the existing worker is destroyed, the extra lib is added, then a new one is initialized with all the libs. The same process happens when a extra lib is disposed of. So, whenever you call addExtraLib you are destroying all parsing, and creating it again for all the inmemory editors and extra libs. In my fork, I’ve fixed this issue by passing making the main thread pass the new extra libs over to the WebWorker on demand, without destroying it. The bulk of the work is here: https://github.com/stefan-lacatus/monaco-typescript/commit/9d9675a28ffc039ec471c4bb240758f81720f84b . The linked commit also deals with bulk updates of the extraLibs.