fix(language-service): Remove getTemplateReferences() from LanguageService API (#33807)
The method `getTemplateReferences()` appears in both the LanguageService interface and LanguageServiceHost interface. It should belong in the latter and not the former, since the former deals with the semantics of the language and not the mechanics. PR Close #33807
This commit is contained in:

committed by
Alex Rickabaugh

parent
af2cca0c7a
commit
0688a28be3
@ -8,8 +8,6 @@
|
||||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {createLanguageService} from '../src/language_service';
|
||||
import {LanguageService} from '../src/types';
|
||||
import {TypeScriptServiceHost} from '../src/typescript_host';
|
||||
|
||||
import {MockTypescriptHost} from './test_utils';
|
||||
@ -18,15 +16,13 @@ describe('references', () => {
|
||||
const mockHost = new MockTypescriptHost(['/app/main.ts']);
|
||||
const service = ts.createLanguageService(mockHost);
|
||||
const ngHost = new TypeScriptServiceHost(mockHost, service);
|
||||
const ngService = createLanguageService(ngHost);
|
||||
|
||||
beforeEach(() => { mockHost.reset(); });
|
||||
|
||||
it('should be able to get template references',
|
||||
() => { expect(() => ngService.getTemplateReferences()).not.toThrow(); });
|
||||
|
||||
it('should be able to determine that test.ng is a template reference',
|
||||
() => { expect(ngService.getTemplateReferences()).toContain('/app/test.ng'); });
|
||||
it('should be able to determine that test.ng is a template reference', () => {
|
||||
const templates = ngHost.getTemplateReferences();
|
||||
expect(templates).toEqual(['/app/test.ng']);
|
||||
});
|
||||
|
||||
it('should be able to get template references for an invalid project', () => {
|
||||
const moduleCode = `
|
||||
@ -42,7 +38,8 @@ describe('references', () => {
|
||||
`;
|
||||
mockHost.addScript('/app/test.module.ts', moduleCode);
|
||||
mockHost.addScript('/app/test.component.ts', classCode);
|
||||
expect(() => { ngService.getTemplateReferences(); }).not.toThrow();
|
||||
const templates = ngHost.getTemplateReferences();
|
||||
expect(templates).toEqual(['/app/test.ng']);
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user