Skip to content
Permalink
Browse files

fix(language-service): Use proper types instead of any (#29942)

PR Close #29942
  • Loading branch information...
kyliau authored and benlesh committed Apr 16, 2019
1 parent 60e9d2d commit 1a56cd5c0b55fc4ed889d934c7ba0c8e5fcd2323
@@ -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__"],
@@ -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<any, TypeScriptServiceHost>();
const projectHostMap = new WeakMap<ts.server.Project, TypeScriptServiceHost>();

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);

@@ -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()) {

0 comments on commit 1a56cd5

Please sign in to comment.
You can’t perform that action at this time.