I can see how to use addExtraLib
in Monaco to add an ambient declaration file. What's not clear is how to use this function with an external declaration file so that Typescript code in the editor can do a:
import * as External from "external"
External.foo();
On the Monaco set-up side, this doesn't seem to work:
// compiler options
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2016,
allowNonTsExtensions: true,
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
module: monaco.languages.typescript.ModuleKind.CommonJS,
noEmit: true,
noLib: true,
typeRoots: ["node_modules/@types"]
});
// extra libraries
monaco.languages.typescript.typescriptDefaults.addExtraLib(
'export declare function foo():string;', 'node_modules/@types/external/index.d.ts');
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false