test(language-service): test project cleanup (#33157)
This PR adds es2015 lib to the `tsconfig.json` of the test project so that `Promise` could be used. Note this only affects diagnostics in the IDE. The tsconfig in Language Service Mock Host is the actual config values used, and it already has es2015 lib. - Other minor cleanup: Rename imports in `main.ts`. - Add more cases to `parsing-cases.ts`, which are tested in later PRs PR Close #33157
This commit is contained in:
parent
4c0726db9c
commit
64aae3a9df
|
@ -11,43 +11,45 @@ import {NgModule} from '@angular/core';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
|
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {ExpectNumericType, LowercasePipe, PrivateReference, WrongFieldReference, WrongSubFieldReference} from './expression-cases';
|
import * as ExpressionCases from './expression-cases';
|
||||||
import {UnknownEven, UnknownPeople, UnknownTrackBy} from './ng-for-cases';
|
import * as NgForCases from './ng-for-cases';
|
||||||
import {ShowIf} from './ng-if-cases';
|
import * as NgIfCases from './ng-if-cases';
|
||||||
import {AttributeBinding, CaseIncompleteOpen, CaseMissingClosing, CaseUnknown, EmptyInterpolation, EventBinding, ForLetIEqual, ForOfEmpty, ForOfLetEmpty, ForUsingComponent, NoValueAttribute, NumberModel, Pipes, PropertyBinding, References, StringModel, TemplateReference, TestComponent, TwoWayBinding} from './parsing-cases';
|
import * as ParsingCases from './parsing-cases';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CommonModule, FormsModule],
|
imports: [CommonModule, FormsModule],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
CaseIncompleteOpen,
|
ExpressionCases.ExpectNumericType,
|
||||||
CaseMissingClosing,
|
ExpressionCases.LowercasePipe,
|
||||||
CaseUnknown,
|
ExpressionCases.PrivateReference,
|
||||||
Pipes,
|
ExpressionCases.WrongFieldReference,
|
||||||
TemplateReference,
|
ExpressionCases.WrongSubFieldReference,
|
||||||
NoValueAttribute,
|
NgForCases.UnknownEven,
|
||||||
AttributeBinding,
|
NgForCases.UnknownPeople,
|
||||||
StringModel,
|
NgForCases.UnknownTrackBy,
|
||||||
NumberModel,
|
NgIfCases.ShowIf,
|
||||||
PropertyBinding,
|
ParsingCases.AsyncForUsingComponent,
|
||||||
EventBinding,
|
ParsingCases.AttributeBinding,
|
||||||
TwoWayBinding,
|
ParsingCases.CaseIncompleteOpen,
|
||||||
EmptyInterpolation,
|
ParsingCases.CaseMissingClosing,
|
||||||
ForOfEmpty,
|
ParsingCases.CaseUnknown,
|
||||||
ForOfLetEmpty,
|
ParsingCases.EmptyInterpolation,
|
||||||
ForLetIEqual,
|
ParsingCases.EventBinding,
|
||||||
ForUsingComponent,
|
ParsingCases.FooComponent,
|
||||||
References,
|
ParsingCases.ForLetIEqual,
|
||||||
TestComponent,
|
ParsingCases.ForOfEmpty,
|
||||||
WrongFieldReference,
|
ParsingCases.ForOfLetEmpty,
|
||||||
WrongSubFieldReference,
|
ParsingCases.ForUsingComponent,
|
||||||
PrivateReference,
|
ParsingCases.NoValueAttribute,
|
||||||
ExpectNumericType,
|
ParsingCases.NumberModel,
|
||||||
UnknownPeople,
|
ParsingCases.Pipes,
|
||||||
UnknownEven,
|
ParsingCases.PropertyBinding,
|
||||||
UnknownTrackBy,
|
ParsingCases.References,
|
||||||
ShowIf,
|
ParsingCases.StringModel,
|
||||||
LowercasePipe,
|
ParsingCases.TemplateReference,
|
||||||
|
ParsingCases.TestComponent,
|
||||||
|
ParsingCases.TwoWayBinding,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
|
|
|
@ -91,9 +91,22 @@ export class NumberModel {
|
||||||
@Output('outputAlias') modelChanged: EventEmitter<number> = new EventEmitter();
|
@Output('outputAlias') modelChanged: EventEmitter<number> = new EventEmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'foo-component',
|
||||||
|
template: `
|
||||||
|
<div string-model ~{string-marker}="text"></div>
|
||||||
|
<div number-model ~{number-marker}="value"></div>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class FooComponent {
|
||||||
|
text: string = 'some text';
|
||||||
|
value: number = 42;
|
||||||
|
}
|
||||||
|
|
||||||
interface Person {
|
interface Person {
|
||||||
name: string;
|
name: string;
|
||||||
age: number;
|
age: number;
|
||||||
|
street: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -125,6 +138,17 @@ export class ForUsingComponent {
|
||||||
people: Person[] = [];
|
people: Person[] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: `
|
||||||
|
<div *ngFor="let person of people | async">
|
||||||
|
{{person.~{async-person-name}name}}
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class AsyncForUsingComponent {
|
||||||
|
people: Promise<Person[]> = Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
<div #div>
|
<div #div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"//00": "This file is used for IDE only, actual compilation options is in MockTypescriptHost in test_utils.ts",
|
"//00": "This file is used for IDE only, actual compilation options is in MockTypescriptHost in test_utils.ts",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"lib": ["es2015"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"baseUrl": "../../../..",
|
"baseUrl": "../../../..",
|
||||||
|
|
|
@ -95,7 +95,7 @@ describe('TypeScriptServiceHost', () => {
|
||||||
const tsLS = ts.createLanguageService(tsLSHost);
|
const tsLS = ts.createLanguageService(tsLSHost);
|
||||||
const ngLSHost = new TypeScriptServiceHost(tsLSHost, tsLS);
|
const ngLSHost = new TypeScriptServiceHost(tsLSHost, tsLS);
|
||||||
const templates = ngLSHost.getTemplates('/app/parsing-cases.ts');
|
const templates = ngLSHost.getTemplates('/app/parsing-cases.ts');
|
||||||
expect(templates.length).toBe(16);
|
expect(templates.length).toBe(18);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to find external template', () => {
|
it('should be able to find external template', () => {
|
||||||
|
|
Loading…
Reference in New Issue