diff --git a/src/index.ts b/src/index.ts index 6ec64ddf..31d753f8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,7 @@ const typescript: PluginImpl = (options) => let tsConfigPath: string | undefined; let servicesHost: LanguageServiceHost; let service: tsTypes.LanguageService; + let documentRegistry: tsTypes.DocumentRegistry; // keep the same DocumentRegistry between watch cycles let noErrors = true; const declarations: { [name: string]: { type: tsTypes.OutputFile; map?: tsTypes.OutputFile } } = {}; const checkedFiles = new Set(); @@ -98,6 +99,7 @@ const typescript: PluginImpl = (options) => pluginOptions.typescript = require("typescript"); } setTypescriptModule(pluginOptions.typescript); + documentRegistry = tsModule.createDocumentRegistry(); const self: Plugin = { @@ -135,8 +137,7 @@ const typescript: PluginImpl = (options) => filter = createFilter(context, pluginOptions, parsedConfig); servicesHost = new LanguageServiceHost(parsedConfig, pluginOptions.transformers, pluginOptions.cwd); - - service = tsModule.createLanguageService(servicesHost, tsModule.createDocumentRegistry()); + service = tsModule.createLanguageService(servicesHost, documentRegistry); servicesHost.setLanguageService(service); // printing compiler option errors