fix(language-service): do not report errors for OpaqueToken (#19427)

`OpaqueToken` was removed from angular but the language-service
should not report errors when it is used for older versions of
angular.
This commit is contained in:
Chuck Jazdzewski
2017-09-28 09:30:34 -07:00
committed by Victor Berchet
parent 82e49230ff
commit c1b029a413
2 changed files with 28 additions and 1 deletions

View File

@ -314,6 +314,28 @@ describe('diagnostics', () => {
expect(diagnostic).toEqual([]);
});
it('should not report errors for using the now removed OpaqueToken (support for v4)', () => {
const app_component = `
import { Component, Inject, OpaqueToken } from '@angular/core';
import { NgForm } from '@angular/common';
export const token = new OpaqueToken();
@Component({
selector: 'example-app',
template: '...'
})
export class AppComponent {
constructor (@Inject(token) value: string) {}
onSubmit(form: NgForm) {}
}
`;
const fileName = '/app/app.component.ts';
mockHost.override(fileName, app_component);
const diagnostics = ngService.getDiagnostics(fileName);
expect(diagnostics).toEqual([]);
});
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
const fileName = '/app/app.component.ts';
const originalContent = mockHost.getFileContent(fileName);