diff --git a/src/tsWorker.ts b/src/tsWorker.ts index fe6172c0..95d06abe 100644 --- a/src/tsWorker.ts +++ b/src/tsWorker.ts @@ -73,9 +73,6 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, monaco.language } else if (fileName in this._extraLibs) { // extra lib text = this._extraLibs[fileName].content; - - } else if (fileName in libFileMap) { - text = libFileMap[fileName]; } else { return; } diff --git a/src/workerManager.ts b/src/workerManager.ts index ff0b560e..6488c7f2 100644 --- a/src/workerManager.ts +++ b/src/workerManager.ts @@ -6,6 +6,7 @@ import { LanguageServiceDefaultsImpl } from './monaco.contribution'; import { TypeScriptWorker } from './tsWorker'; +import { libFileMap } from './lib/lib' import IDisposable = monaco.IDisposable; import Uri = monaco.Uri; @@ -60,6 +61,12 @@ export class WorkerManager { private _getClient(): Promise { if (!this._client) { + // Adds all of the .d.ts lib files into Monaco as editor models, + // this allows themm to show up in peek (and allow editing if desired). + for (const key in libFileMap) { + monaco.editor.createModel(libFileMap[key], "ts", monaco.Uri.file(key)) + } + this._worker = monaco.editor.createWebWorker({ // module that exports the create() method and returns a `TypeScriptWorker` instance @@ -72,7 +79,7 @@ export class WorkerManager { // passed in to the create() method createData: { compilerOptions: this._defaults.getCompilerOptions(), - extraLibs: this._defaults.getExtraLibs() + extraLibs: this._defaults.getExtraLibs(), } });