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

PR Close #29942
This commit is contained in:
Keen Yee Liau 2019-04-16 16:36:47 -07:00 committed by Ben Lesh
parent 60e9d2da4f
commit 1a56cd5c0b
3 changed files with 15 additions and 8 deletions

View File

@ -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__"],

View File

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

View File

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