Through extensive research, it has come to light that the TypeScript LanguageService
interface is somewhat exposed through a worker proxy object. This could be attributed to the service being in a separate thread where messages are sent to it, hence the necessity of using promises.
To simplify things, I carefully examined the functions exposed on the returned object and formulated this definition; hopefully, it proves beneficial to someone:
namespace ts {
export interface IMonacoTypeScriptServiceProxy {
// List of exposed functions
}
}
The usage of this interface is demonstrated below:
// Sample code showcasing how to use the interface
The function
getEmitOutput(uri: string, emitOnlyDtsFiles?: boolean)
can now be invoked. The parameter
uri
represents the filename, converted from a
monaco.Uri
to a string (in monaco terminology, a
model
refers to a single file in the editor). Therefore:
// Example of invoking the getEmitOutput function
Calling this function will return not only the transpiled JavaScript but also any other available files! Enjoy the benefits.