refactor: add types (#9116)

This commit is contained in:
Victor Berchet
2016-06-09 11:04:15 -07:00
committed by Miško Hevery
parent b60eecfc47
commit 7ce0fc7d47
64 changed files with 711 additions and 718 deletions

View File

@ -36,7 +36,7 @@ export function main() {
describe('inline template', () => {
it('should store the template',
inject([AsyncTestCompleter, DirectiveNormalizer],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer) => {
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
template: 'a',
@ -53,7 +53,7 @@ export function main() {
it('should resolve styles on the annotation against the moduleUrl',
inject([AsyncTestCompleter, DirectiveNormalizer],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer) => {
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
template: '',
@ -69,7 +69,7 @@ export function main() {
it('should resolve styles in the template against the moduleUrl',
inject([AsyncTestCompleter, DirectiveNormalizer],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer) => {
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
template: '<style>@import test.css</style>',
@ -85,7 +85,7 @@ export function main() {
it('should use ViewEncapsulation.Emulated by default',
inject([AsyncTestCompleter, DirectiveNormalizer],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer) => {
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
template: '',
@ -101,7 +101,7 @@ export function main() {
it('should use default encapsulation provided by CompilerConfig',
inject([AsyncTestCompleter, CompilerConfig , DirectiveNormalizer],
(async: any /** TODO #9100 */, config: CompilerConfig, normalizer: DirectiveNormalizer) => {
(async: AsyncTestCompleter, config: CompilerConfig, normalizer: DirectiveNormalizer) => {
config.defaultEncapsulation = ViewEncapsulation.None;
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
@ -121,7 +121,7 @@ export function main() {
it('should load a template from a url that is resolved against moduleUrl',
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
xhr.expect('package:some/module/sometplurl.html', 'a');
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
@ -141,7 +141,7 @@ export function main() {
it('should resolve styles on the annotation against the moduleUrl',
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
xhr.expect('package:some/module/tpl/sometplurl.html', '');
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({
encapsulation: null,
@ -159,7 +159,7 @@ export function main() {
it('should resolve styles in the template against the templateUrl',
inject([AsyncTestCompleter, DirectiveNormalizer, XHR],
(async: any /** TODO #9100 */, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
(async: AsyncTestCompleter, normalizer: DirectiveNormalizer, xhr: MockXHR) => {
xhr.expect('package:some/module/tpl/sometplurl.html',
'<style>@import test.css</style>');
normalizer.normalizeTemplate(dirType, new CompileTemplateMetadata({

View File

@ -43,7 +43,7 @@ export function main() {
var injector: Injector;
var sharedStylesHost: SharedStylesHost;
beforeEach(inject([Injector, SharedStylesHost], (_injector: any /** TODO #9100 */, _sharedStylesHost: any /** TODO #9100 */) => {
beforeEach(inject([Injector, SharedStylesHost], (_injector: Injector, _sharedStylesHost: SharedStylesHost) => {
injector = _injector;
sharedStylesHost = _sharedStylesHost;
}));

View File

@ -82,7 +82,7 @@ export function main() {
console = new ArrayConsole();
return [{provide: Console, useValue: console}];
});
beforeEach(inject([TemplateParser], (parser: any /** TODO #9100 */) => {
beforeEach(inject([TemplateParser], (parser: TemplateParser) => {
var component = CompileDirectiveMetadata.create({
selector: 'root',
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'Root'}),

View File

@ -192,7 +192,7 @@ class DirectiveListComp {
export function main() {
describe('test component builder', function() {
it('should instantiate a component with valid DOM',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
componentFixture.detectChanges();
@ -203,7 +203,7 @@ export function main() {
}));
it('should allow changing members of the component',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(MyIfComp).then((componentFixture) => {
componentFixture.detectChanges();
@ -218,7 +218,7 @@ export function main() {
}));
it('should override a template',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideTemplate(MockChildComp, '<span>Mock</span>')
.createAsync(MockChildComp)
@ -231,7 +231,7 @@ export function main() {
}));
it('should override a view',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideView(ChildComp,
new ViewMetadata({template: '<span>Modified {{childBinding}}</span>'}))
@ -245,7 +245,7 @@ export function main() {
}));
it('should override component dependencies',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideDirective(ParentComp, ChildComp, MockChildComp)
.createAsync(ParentComp)
@ -258,7 +258,7 @@ export function main() {
}));
it('should override items from a list',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideDirective(DirectiveListComp, ListDir1, ListDir1Alt)
.createAsync(DirectiveListComp)
@ -271,7 +271,7 @@ export function main() {
}));
it("should override child component's dependencies",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideDirective(ParentComp, ChildComp, ChildWithChildComp)
.overrideDirective(ChildWithChildComp, ChildChildComp, MockChildChildComp)
@ -286,7 +286,7 @@ export function main() {
}));
it('should override a provider',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideProviders(TestBindingsComp,
[{provide: FancyService, useClass: MockFancyService}])
@ -301,7 +301,7 @@ export function main() {
it('should override a viewBinding',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.overrideViewProviders(TestViewBindingsComp,
[{provide: FancyService, useClass: MockFancyService}])
@ -318,7 +318,7 @@ export function main() {
describe('ComponentFixture', () => {
it('should auto detect changes if autoDetectChanges is called',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AutoDetectComp)
.then((componentFixture) => {
@ -338,7 +338,7 @@ export function main() {
it('should auto detect changes if ComponentFixtureAutoDetect is provided as true',
withProviders(() => [{provide: ComponentFixtureAutoDetect, useValue: true}])
.inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AutoDetectComp)
.then((componentFixture) => {
@ -354,7 +354,7 @@ export function main() {
it('should signal through whenStable when the fixture is stable (autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => {
componentFixture.autoDetectChanges();
@ -377,7 +377,7 @@ export function main() {
it('should signal through isStable when the fixture is stable (no autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncComp).then((componentFixture) => {
componentFixture.detectChanges();
@ -401,7 +401,7 @@ export function main() {
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp)
.then((componentFixture) => {
@ -426,7 +426,7 @@ export function main() {
it('should wait for macroTask(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncTimeoutComp)
.then((componentFixture) => {
@ -452,7 +452,7 @@ export function main() {
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp)
.then((componentFixture) => {
@ -477,7 +477,7 @@ export function main() {
it('should wait for nested macroTasks(setTimeout) while checking for whenStable ' +
'(no autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(NestedAsyncTimeoutComp)
.then((componentFixture) => {
@ -502,7 +502,7 @@ export function main() {
it('should stabilize after async task in change detection (autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp)
.then((componentFixture) => {
@ -523,7 +523,7 @@ export function main() {
it('should stabilize after async task in change detection(no autoDetectChanges)',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(AsyncChangeComp)
.then((componentFixture) => {
@ -554,7 +554,7 @@ export function main() {
it('calling autoDetectChanges raises an error', () => {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async: any /** TODO #9100 */) => {
async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(() => {
componentFixture.autoDetectChanges();
@ -566,7 +566,7 @@ export function main() {
it('should instantiate a component with valid DOM',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(ChildComp).then((componentFixture) => {
expect(componentFixture.ngZone).toBeNull();
@ -578,7 +578,7 @@ export function main() {
it('should allow changing members of the component',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
tcb.createAsync(MyIfComp).then((componentFixture) => {
componentFixture.detectChanges();
@ -596,7 +596,7 @@ export function main() {
describe('createSync', () => {
it('should create components',
inject([ComponentResolver, TestComponentBuilder, AsyncTestCompleter],
(cr: ComponentResolver, tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
(cr: ComponentResolver, tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
cr.resolveComponent(MyIfComp).then((cmpFactory) => {
let componentFixture = tcb.createSync(cmpFactory);

View File

@ -42,7 +42,7 @@ export function main() {
PromiseWrapper.then(request, onResponse, onError);
}
it('should return a response from the definitions', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
it('should return a response from the definitions', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo';
var response = 'bar';
xhr.when(url, response);
@ -50,7 +50,7 @@ export function main() {
xhr.flush();
}));
it('should return an error from the definitions', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
it('should return an error from the definitions', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo';
var response: any /** TODO #9100 */ = null;
xhr.when(url, response);
@ -58,7 +58,7 @@ export function main() {
xhr.flush();
}));
it('should return a response from the expectations', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
it('should return a response from the expectations', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo';
var response = 'bar';
xhr.expect(url, response);
@ -66,7 +66,7 @@ export function main() {
xhr.flush();
}));
it('should return an error from the expectations', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
it('should return an error from the expectations', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo';
var response: any /** TODO #9100 */ = null;
xhr.expect(url, response);
@ -83,7 +83,7 @@ export function main() {
expect(() => { xhr.flush(); }).toThrowError('Unexpected request /foo');
});
it('should return expectations before definitions', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
it('should return expectations before definitions', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo';
xhr.when(url, 'when');
xhr.expect(url, 'expect');

View File

@ -93,11 +93,9 @@ export class MockXHR extends XHR {
}
class _PendingRequest {
url: string;
completer: PromiseCompleter<string>;
constructor(url: any /** TODO #9100 */) {
this.url = url;
constructor(public url: string) {
this.completer = PromiseWrapper.completer();
}