diff --git a/packages/language-service/bundles/BUILD.bazel b/packages/language-service/bundles/BUILD.bazel index 7206dcc92b..20501ae5c9 100644 --- a/packages/language-service/bundles/BUILD.bazel +++ b/packages/language-service/bundles/BUILD.bazel @@ -7,6 +7,7 @@ ls_rollup_bundle( "fs": "fs", "path": "path", "typescript": "ts", + "typescript/lib/tsserverlibrary": "tsserverlibrary", }, license_banner = "banner.js.txt", visibility = ["//packages/language-service:__pkg__"], diff --git a/packages/language-service/src/ts_plugin.ts b/packages/language-service/src/ts_plugin.ts index 4bd0f83c60..ac39c726ba 100644 --- a/packages/language-service/src/ts_plugin.ts +++ b/packages/language-service/src/ts_plugin.ts @@ -6,18 +6,19 @@ * found in the LICENSE file at https://angular.io/license */ -import * as ts from 'typescript'; +import * as ts from 'typescript/lib/tsserverlibrary'; import {createLanguageService} from './language_service'; import {Completion, Diagnostic, DiagnosticMessageChain} from './types'; import {TypeScriptServiceHost} from './typescript_host'; -const projectHostMap = new WeakMap(); +const projectHostMap = new WeakMap(); -export function getExternalFiles(project: any): string[]|undefined { +export function getExternalFiles(project: ts.server.Project): string[]|undefined { const host = projectHostMap.get(project); if (host) { - return host.getTemplateReferences(); + const externalFiles = host.getTemplateReferences(); + return externalFiles; } } @@ -62,7 +63,7 @@ function diagnosticToDiagnostic(d: Diagnostic, file: ts.SourceFile): ts.Diagnost return result; } -export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageService { +export function create(info: ts.server.PluginCreateInfo): ts.LanguageService { const oldLS: ts.LanguageService = info.languageService; const proxy: ts.LanguageService = Object.assign({}, oldLS); const logger = info.project.projectService.logger; @@ -78,7 +79,7 @@ export function create(info: any /* ts.server.PluginCreateInfo */): ts.LanguageS } const serviceHost = new TypeScriptServiceHost(info.languageServiceHost, oldLS); - const ls = createLanguageService(serviceHost as any); + const ls = createLanguageService(serviceHost); serviceHost.setSite(ls); projectHostMap.set(info.project, serviceHost); diff --git a/packages/language-service/test/ts_plugin_spec.ts b/packages/language-service/test/ts_plugin_spec.ts index e792a8d439..5948391008 100644 --- a/packages/language-service/test/ts_plugin_spec.ts +++ b/packages/language-service/test/ts_plugin_spec.ts @@ -32,8 +32,13 @@ describe('plugin', () => { }); - let plugin = create( - {ts: ts, languageService: service, project: mockProject, languageServiceHost: mockHost}); + let plugin = create({ + languageService: service, + project: mockProject as any, + languageServiceHost: mockHost, + serverHost: {} as any, + config: {}, + }); it('should not report template errors on tour of heroes', () => { for (let source of program !.getSourceFiles()) {