From 4450e7b24620ff2d6a02796217c11fb9aebed154 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 15 Jun 2016 16:45:19 -0700 Subject: [PATCH] cleanup(router): enable noImplicitAny and noImplicntReturns --- .../@angular/router/src/apply_redirects.ts | 16 ++-- .../router/src/common_router_providers.ts | 12 +-- .../@angular/router/src/create_url_tree.ts | 12 +-- modules/@angular/router/src/recognize.ts | 13 +-- modules/@angular/router/src/router.ts | 24 +++--- modules/@angular/router/src/url_serializer.ts | 16 ++-- modules/@angular/router/src/url_tree.ts | 12 +-- .../@angular/router/src/utils/collection.ts | 10 +-- .../router/test/apply_redirects.spec.ts | 26 +++--- .../router/test/create_router_state.spec.ts | 2 +- .../@angular/router/test/recognize.spec.ts | 56 ++++++------- modules/@angular/router/test/router.spec.ts | 79 ++++++++++--------- modules/@angular/router/tsconfig.json | 3 +- .../@angular/router/tsconfig.publish.es5.json | 3 +- .../@angular/router/tsconfig.publish.esm.json | 3 +- 15 files changed, 154 insertions(+), 133 deletions(-) diff --git a/modules/@angular/router/src/apply_redirects.ts b/modules/@angular/router/src/apply_redirects.ts index bb521eef91..ca9c248e3e 100644 --- a/modules/@angular/router/src/apply_redirects.ts +++ b/modules/@angular/router/src/apply_redirects.ts @@ -1,4 +1,5 @@ import {Observable} from 'rxjs/Observable'; +import {Observer} from 'rxjs/Observer'; import {of } from 'rxjs/observable/of'; import {Route, RouterConfig} from './config'; @@ -21,9 +22,10 @@ export function applyRedirects(urlTree: UrlTree, config: RouterConfig): Observab urlTree, new UrlSegment([], {[PRIMARY_OUTLET]: new UrlSegment(e.paths, {})})); } else if (e instanceof NoMatch) { return new Observable( - obs => obs.error(new Error(`Cannot match any routes: '${e.segment}'`))); + (obs: Observer) => + obs.error(new Error(`Cannot match any routes: '${e.segment}'`))); } else { - return new Observable(obs => obs.error(e)); + return new Observable((obs: Observer) => obs.error(e)); } } } @@ -128,7 +130,11 @@ function matchPathsWithParamsAgainstRoute( } } -function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) { +function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]): { + consumedPaths: UrlPathWithParams[], + lastChild: number, + positionalParamSegments: {[k: string]: UrlPathWithParams} +} { if (route.index || route.path === '' || route.path === '/') { if (route.terminal && (Object.keys(segment.children).length > 0 || paths.length > 0)) { throw new NoMatch(); @@ -139,8 +145,8 @@ function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) { const path = route.path.startsWith('/') ? route.path.substring(1) : route.path; const parts = path.split('/'); - const positionalParamSegments = {}; - const consumedPaths = []; + const positionalParamSegments: {[k: string]: UrlPathWithParams} = {}; + const consumedPaths: UrlPathWithParams[] = []; let currentIndex = 0; diff --git a/modules/@angular/router/src/common_router_providers.ts b/modules/@angular/router/src/common_router_providers.ts index 8feb2c5e19..c42050552f 100644 --- a/modules/@angular/router/src/common_router_providers.ts +++ b/modules/@angular/router/src/common_router_providers.ts @@ -13,7 +13,9 @@ export const ROUTER_OPTIONS = new OpaqueToken('ROUTER_OPTIONS'); export interface ExtraOptions { enableTracing?: boolean; } export function setupRouter( - ref, resolver, urlSerializer, outletMap, location, injector, config, opts) { + ref: ApplicationRef, resolver: ComponentResolver, urlSerializer: UrlSerializer, + outletMap: RouterOutletMap, location: Location, injector: Injector, config: RouterConfig, + opts: ExtraOptions) { if (ref.componentTypes.length == 0) { throw new Error('Bootstrap at least one component before injecting Router.'); } @@ -38,15 +40,15 @@ export function setupRouterInitializer(injector: Injector) { // https://github.com/angular/angular/issues/9101 // Delay the router instantiation to avoid circular dependency (ApplicationRef -> // APP_INITIALIZER -> Router) - setTimeout(_ => { + setTimeout(() => { const appRef = injector.get(ApplicationRef); if (appRef.componentTypes.length == 0) { - appRef.registerBootstrapListener((_) => { injector.get(Router).initialNavigation(); }); + appRef.registerBootstrapListener(() => { injector.get(Router).initialNavigation(); }); } else { injector.get(Router).initialNavigation(); } }, 0); - return _ => null; + return (): any => null; } /** @@ -83,7 +85,7 @@ export function provideRouter(_config: RouterConfig, _opts: ExtraOptions): any[] }, RouterOutletMap, - {provide: ActivatedRoute, useFactory: (r) => r.routerState.root, deps: [Router]}, + {provide: ActivatedRoute, useFactory: (r: Router) => r.routerState.root, deps: [Router]}, // Trigger initial navigation {provide: APP_INITIALIZER, multi: true, useFactory: setupRouterInitializer, deps: [Injector]} diff --git a/modules/@angular/router/src/create_url_tree.ts b/modules/@angular/router/src/create_url_tree.ts index 88ad1dd72d..1030409047 100644 --- a/modules/@angular/router/src/create_url_tree.ts +++ b/modules/@angular/router/src/create_url_tree.ts @@ -39,11 +39,11 @@ function tree( function replaceSegment( current: UrlSegment, oldSegment: UrlSegment, newSegment: UrlSegment): UrlSegment { const children: {[key: string]: UrlSegment} = {}; - forEach(current.children, (c, k) => { + forEach(current.children, (c: UrlSegment, outletName: string) => { if (c === oldSegment) { - children[k] = newSegment; + children[outletName] = newSegment; } else { - children[k] = replaceSegment(c, oldSegment, newSegment); + children[outletName] = replaceSegment(c, oldSegment, newSegment); } }); return new UrlSegment(current.pathsWithParams, children); @@ -66,7 +66,7 @@ function normalizeCommands(commands: any[]): NormalizedNavigationCommands { let numberOfDoubleDots = 0; let isAbsolute = false; - const res = []; + const res: any[] = []; for (let i = 0; i < commands.length; ++i) { const c = commands[i]; @@ -164,7 +164,7 @@ function updateSegmentChildren( const outlet = getOutlet(commands); const children: {[key: string]: UrlSegment} = {}; children[outlet] = updateSegment(segment.children[outlet], startIndex, commands); - forEach(segment.children, (child, childOutlet) => { + forEach(segment.children, (child: UrlSegment, childOutlet: string) => { if (childOutlet !== outlet) { children[childOutlet] = child; } @@ -224,7 +224,7 @@ function createNewSegment(segment: UrlSegment, startIndex: number, commands: any function stringify(params: {[key: string]: any}): {[key: string]: string} { const res: {[key: string]: string} = {}; - forEach(params, (v, k) => res[k] = `${v}`); + forEach(params, (v: any, k: string) => res[k] = `${v}`); return res; } diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index 3081f9f05a..bb2a2017b3 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -1,5 +1,6 @@ import {Type} from '@angular/core'; import {Observable} from 'rxjs/Observable'; +import {Observer} from 'rxjs/Observer'; import {of } from 'rxjs/observable/of'; import {Route, RouterConfig} from './config'; @@ -25,9 +26,11 @@ export function recognize( } catch (e) { if (e instanceof NoMatch) { return new Observable( - obs => obs.error(new Error(`Cannot match any routes: '${e.segment}'`))); + (obs: Observer) => + obs.error(new Error(`Cannot match any routes: '${e.segment}'`))); } else { - return new Observable(obs => obs.error(e)); + return new Observable( + (obs: Observer) => obs.error(e)); } } } @@ -119,7 +122,7 @@ function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) { const path = route.path.startsWith('/') ? route.path.substring(1) : route.path; const parts = path.split('/'); const posParameters: {[key: string]: any} = {}; - const consumedPaths = []; + const consumedPaths: UrlPathWithParams[] = []; let currentIndex = 0; @@ -147,11 +150,11 @@ function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) { } function checkOutletNameUniqueness(nodes: TreeNode[]): void { - const names = {}; + const names: {[k: string]: ActivatedRouteSnapshot} = {}; nodes.forEach(n => { let routeWithSameOutletName = names[n.value.outlet]; if (routeWithSameOutletName) { - const p = routeWithSameOutletName.urlSegments.map(s => s.toString()).join('/'); + const p = routeWithSameOutletName.url.map(s => s.toString()).join('/'); const c = n.value.url.map(s => s.toString()).join('/'); throw new Error(`Two segments cannot have the same outlet name: '${p}' and '${c}'.`); } diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index 01d38a0ce0..b5347be38d 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -265,8 +265,8 @@ export class Router { } return new Promise((resolvePromise, rejectPromise) => { - let updatedUrl; - let state; + let updatedUrl: UrlTree; + let state: RouterState; applyRedirects(url, this.config) .mergeMap(u => { updatedUrl = u; @@ -293,7 +293,7 @@ export class Router { .check(this.outletMap); }) - .forEach((shouldActivate) => { + .forEach((shouldActivate: boolean) => { if (!shouldActivate || id !== this.navigationId) { this.routerEvents.next(new NavigationCancel(id, this.serializeUrl(url))); return Promise.resolve(false); @@ -311,6 +311,7 @@ export class Router { this.location.go(path); } } + return Promise.resolve(true); }) .then( () => { @@ -335,7 +336,7 @@ class CanDeactivate { } class GuardChecks { - private checks = []; + private checks: Array = []; constructor( private future: RouterStateSnapshot, private curr: RouterStateSnapshot, private injector: Injector) {} @@ -368,7 +369,9 @@ class GuardChecks { this.traverseRoutes(c, prevChildren[c.value.outlet], outletMap); delete prevChildren[c.value.outlet]; }); - forEach(prevChildren, (v, k) => this.deactivateOutletAndItChildren(v, outletMap._outlets[k])); + forEach( + prevChildren, + (v: any, k: string) => this.deactivateOutletAndItChildren(v, outletMap._outlets[k])); } traverseRoutes( @@ -392,7 +395,7 @@ class GuardChecks { private deactivateOutletAndItChildren(route: ActivatedRouteSnapshot, outlet: RouterOutlet): void { if (outlet && outlet.isActivated) { - forEach(outlet.outletMap._outlets, (v, k) => { + forEach(outlet.outletMap._outlets, (v: RouterOutlet) => { if (v.isActivated) { this.deactivateOutletAndItChildren(v.activatedRoute.snapshot, v); } @@ -461,7 +464,9 @@ class ActivateRoutes { this.activateRoutes(c, prevChildren[c.value.outlet], outletMap); delete prevChildren[c.value.outlet]; }); - forEach(prevChildren, (v, k) => this.deactivateOutletAndItChildren(outletMap._outlets[k])); + forEach( + prevChildren, + (v: any, k: string) => this.deactivateOutletAndItChildren(outletMap._outlets[k])); } activateRoutes( @@ -495,7 +500,8 @@ class ActivateRoutes { private deactivateOutletAndItChildren(outlet: RouterOutlet): void { if (outlet && outlet.isActivated) { - forEach(outlet.outletMap._outlets, (v, k) => this.deactivateOutletAndItChildren(v)); + forEach( + outlet.outletMap._outlets, (v: RouterOutlet) => this.deactivateOutletAndItChildren(v)); outlet.deactivate(); } } @@ -512,7 +518,7 @@ function pushQueryParamsAndFragment(state: RouterState): void { } function nodeChildrenAsMap(node: TreeNode) { - return node ? node.children.reduce((m, c) => { + return node ? node.children.reduce((m: any, c: TreeNode) => { m[c.value.outlet] = c; return m; }, {}) : {}; diff --git a/modules/@angular/router/src/url_serializer.ts b/modules/@angular/router/src/url_serializer.ts index e0fa42635c..c5c8958667 100644 --- a/modules/@angular/router/src/url_serializer.ts +++ b/modules/@angular/router/src/url_serializer.ts @@ -43,8 +43,8 @@ export function serializePaths(segment: UrlSegment): string { function serializeSegment(segment: UrlSegment, root: boolean): string { if (segment.children[PRIMARY_OUTLET] && root) { const primary = serializeSegment(segment.children[PRIMARY_OUTLET], false); - const children = []; - forEach(segment.children, (v, k) => { + const children: string[] = []; + forEach(segment.children, (v: UrlSegment, k: string) => { if (k !== PRIMARY_OUTLET) { children.push(`${k}:${serializeSegment(v, false)}`); } @@ -56,7 +56,7 @@ function serializeSegment(segment: UrlSegment, root: boolean): string { } } else if (segment.children[PRIMARY_OUTLET] && !root) { const children = [serializeSegment(segment.children[PRIMARY_OUTLET], false)]; - forEach(segment.children, (v, k) => { + forEach(segment.children, (v: UrlSegment, k: string) => { if (k !== PRIMARY_OUTLET) { children.push(`${k}:${serializeSegment(v, false)}`); } @@ -71,15 +71,15 @@ function serializeChildren(segment: UrlSegment) { if (segment.children[PRIMARY_OUTLET]) { const primary = serializePaths(segment.children[PRIMARY_OUTLET]); - const secondary = []; - forEach(segment.children, (v, k) => { + const secondary: string[] = []; + forEach(segment.children, (v: UrlSegment, k: string) => { if (k !== PRIMARY_OUTLET) { secondary.push(`${k}:${serializePaths(v)}${serializeChildren(v)}`); } }); const secondaryStr = secondary.length > 0 ? `(${secondary.join('//')})` : ''; const primaryChildren = serializeChildren(segment.children[PRIMARY_OUTLET]); - const primaryChildrenStr = primaryChildren ? `/${primaryChildren}` : ''; + const primaryChildrenStr: string = primaryChildren ? `/${primaryChildren}` : ''; return `${primary}${secondaryStr}${primaryChildrenStr}`; } else { return ''; @@ -103,7 +103,7 @@ class Pair { constructor(public first: A, public second: B) {} } function pairs(obj: {[key: string]: T}): Pair[] { - const res = []; + const res: Pair[] = []; for (let prop in obj) { if (obj.hasOwnProperty(prop)) { res.push(new Pair(prop, obj[prop])); @@ -260,7 +260,7 @@ class UrlParser { while (!this.peekStartsWith(')') && this.remaining.length > 0) { let path = matchPathWithParams(this.remaining); - let outletName; + let outletName: string; if (path.indexOf(':') > -1) { outletName = path.substr(0, path.indexOf(':')); this.capture(outletName); diff --git a/modules/@angular/router/src/url_tree.ts b/modules/@angular/router/src/url_tree.ts index 1c83a6f641..9cb4a7b711 100644 --- a/modules/@angular/router/src/url_tree.ts +++ b/modules/@angular/router/src/url_tree.ts @@ -71,7 +71,7 @@ export class UrlSegment { public parent: UrlSegment = null; constructor( public pathsWithParams: UrlPathWithParams[], public children: {[key: string]: UrlSegment}) { - forEach(children, (v, k) => v.parent = this); + forEach(children, (v: any, k: any) => v.parent = this); } toString(): string { return serializePaths(this); } @@ -102,12 +102,12 @@ export function equalPath(a: UrlPathWithParams[], b: UrlPathWithParams[]): boole export function mapChildren(segment: UrlSegment, fn: (v: UrlSegment, k: string) => UrlSegment): {[name: string]: UrlSegment} { const newChildren: {[name: string]: UrlSegment} = {}; - forEach(segment.children, (child, childOutlet) => { + forEach(segment.children, (child: UrlSegment, childOutlet: string) => { if (childOutlet === PRIMARY_OUTLET) { newChildren[childOutlet] = fn(child, childOutlet); } }); - forEach(segment.children, (child, childOutlet) => { + forEach(segment.children, (child: UrlSegment, childOutlet: string) => { if (childOutlet !== PRIMARY_OUTLET) { newChildren[childOutlet] = fn(child, childOutlet); } @@ -117,13 +117,13 @@ export function mapChildren(segment: UrlSegment, fn: (v: UrlSegment, k: string) export function mapChildrenIntoArray( segment: UrlSegment, fn: (v: UrlSegment, k: string) => T[]): T[] { - let res = []; - forEach(segment.children, (child, childOutlet) => { + let res: T[] = []; + forEach(segment.children, (child: UrlSegment, childOutlet: string) => { if (childOutlet === PRIMARY_OUTLET) { res = res.concat(fn(child, childOutlet)); } }); - forEach(segment.children, (child, childOutlet) => { + forEach(segment.children, (child: UrlSegment, childOutlet: string) => { if (childOutlet !== PRIMARY_OUTLET) { res = res.concat(fn(child, childOutlet)); } diff --git a/modules/@angular/router/src/utils/collection.ts b/modules/@angular/router/src/utils/collection.ts index 1dd0e16b67..cb17c7f820 100644 --- a/modules/@angular/router/src/utils/collection.ts +++ b/modules/@angular/router/src/utils/collection.ts @@ -1,11 +1,11 @@ export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): boolean { - var k1 = Object.keys(a); - var k2 = Object.keys(b); + const k1 = Object.keys(a); + const k2 = Object.keys(b); if (k1.length != k2.length) { return false; } - var key; - for (var i = 0; i < k1.length; i++) { + let key: string; + for (let i = 0; i < k1.length; i++) { key = k1[i]; if (a[key] !== b[key]) { return false; @@ -15,7 +15,7 @@ export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): bool } export function flatten(a: T[][]): T[] { - const target = []; + const target: T[] = []; for (let i = 0; i < a.length; ++i) { for (let j = 0; j < a[i].length; ++j) { target.push(a[i][j]); diff --git a/modules/@angular/router/test/apply_redirects.spec.ts b/modules/@angular/router/test/apply_redirects.spec.ts index 608b882cac..25c57c8847 100644 --- a/modules/@angular/router/test/apply_redirects.spec.ts +++ b/modules/@angular/router/test/apply_redirects.spec.ts @@ -8,7 +8,7 @@ describe('applyRedirects', () => { it("should return the same url tree when no redirects", () => { checkRedirect([ {path: 'a', component: ComponentA, children: [{path: 'b', component: ComponentB}]} - ], "/a/b", t => { + ], "/a/b", (t:UrlTree) => { compareTrees(t, tree('/a/b')); }); }); @@ -17,7 +17,7 @@ describe('applyRedirects', () => { checkRedirect([ {path: 'a/b', redirectTo: 'a/b/c'}, {path: '**', component: ComponentC} - ], "/a/b", t => { + ], "/a/b", (t:UrlTree) => { compareTrees(t, tree('/a/b/c')); }); }); @@ -26,7 +26,7 @@ describe('applyRedirects', () => { checkRedirect([ {path: 'a/:aid/b/:bid', redirectTo: 'newa/:aid/newb/:bid'}, {path: '**', component: ComponentC} - ], "/a/1/b/2", t => { + ], "/a/1/b/2", (t:UrlTree) => { compareTrees(t, tree('/newa/1/newb/2')); }); }); @@ -43,7 +43,7 @@ describe('applyRedirects', () => { checkRedirect([ {path: 'a/:id', redirectTo: 'd/a/:id/e'}, {path: '**', component: ComponentC} - ], "/a;p1=1/1;p2=2", t => { + ], "/a;p1=1/1;p2=2", (t:UrlTree) => { compareTrees(t, tree('/d/a;p1=1/1;p2=2/e')); }); }); @@ -53,7 +53,7 @@ describe('applyRedirects', () => { {path: 'a/:id', redirectTo: 'd/a/:id/e'}, {path: 'c/d', component: ComponentA, outlet: 'aux'}, {path: '**', component: ComponentC} - ], "/a/1(aux:c/d)", t => { + ], "/a/1(aux:c/d)", (t:UrlTree) => { compareTrees(t, tree('/d/a/1/e(aux:c/d)')); }); }); @@ -63,7 +63,7 @@ describe('applyRedirects', () => { {path: 'a/:id', component: ComponentA}, {path: 'c/d', redirectTo: 'f/c/d/e', outlet: 'aux'}, {path: '**', component: ComponentC, outlet: 'aux'} - ], "/a/1(aux:c/d)", t => { + ], "/a/1(aux:c/d)", (t:UrlTree) => { compareTrees(t, tree('/a/1(aux:f/c/d/e)')); }); }); @@ -74,7 +74,7 @@ describe('applyRedirects', () => { {path: 'b', component: ComponentB}, ]}, {path: 'c', redirectTo: 'a'} - ], "c/b", t => { + ], "c/b", (t:UrlTree) => { compareTrees(t, tree('a/b')); }); }); @@ -85,7 +85,7 @@ describe('applyRedirects', () => { {path: 'b', component: ComponentB}, ]}, {path: '', redirectTo: 'a'} - ], "b", t => { + ], "b", (t:UrlTree) => { compareTrees(t, tree('a/b')); }); }); @@ -96,7 +96,7 @@ describe('applyRedirects', () => { {path: 'b', component: ComponentB}, ]}, {path: '', redirectTo: '/a/b'} - ], "", t => { + ], "", (t:UrlTree) => { compareTrees(t, tree('a/b')); }); }); @@ -108,7 +108,7 @@ describe('applyRedirects', () => { {path: '', redirectTo: 'b'} ]}, {path: '', redirectTo: 'a'} - ], "", t => { + ], "", (t:UrlTree) => { compareTrees(t, tree('a/b')); }); }); @@ -120,7 +120,7 @@ describe('applyRedirects', () => { {path: '', redirectTo: 'b'} ]}, {path: 'a', redirectTo: ''} - ], "a", t => { + ], "a", (t:UrlTree) => { compareTrees(t, tree('b')); }); }); @@ -144,7 +144,7 @@ describe('applyRedirects', () => { checkRedirect([ {path: '404', component: ComponentA}, {path: '**', redirectTo: '/404'}, - ], "/a/1(aux:c/d)", t => { + ], "/a/1(aux:c/d)", (t:UrlTree) => { compareTrees(t, tree('/404')); }); }); @@ -155,7 +155,7 @@ describe('applyRedirects', () => { {path: 'b/:id', redirectTo: '/global/:id'} ]}, {path: '**', component: ComponentC} - ], "/a/b/1", t => { + ], "/a/b/1", (t:UrlTree) => { compareTrees(t, tree('/global/1')); }); }); diff --git a/modules/@angular/router/test/create_router_state.spec.ts b/modules/@angular/router/test/create_router_state.spec.ts index 0079dc33ce..4cfa90bc8d 100644 --- a/modules/@angular/router/test/create_router_state.spec.ts +++ b/modules/@angular/router/test/create_router_state.spec.ts @@ -56,7 +56,7 @@ function advanceNode(node: TreeNode): void { } function createState(config: RouterConfig, url: string): RouterStateSnapshot { - let res; + let res: RouterStateSnapshot; recognize(RootComponent, config, tree(url), url).forEach(s => res = s); return res; } diff --git a/modules/@angular/router/test/recognize.spec.ts b/modules/@angular/router/test/recognize.spec.ts index b585cc047b..adaeb86201 100644 --- a/modules/@angular/router/test/recognize.spec.ts +++ b/modules/@angular/router/test/recognize.spec.ts @@ -1,7 +1,7 @@ import {DefaultUrlSerializer} from '../src/url_serializer'; import {UrlTree} from '../src/url_tree'; import {Params, PRIMARY_OUTLET} from '../src/shared'; -import {ActivatedRouteSnapshot} from '../src/router_state'; +import {ActivatedRouteSnapshot, RouterStateSnapshot} from '../src/router_state'; import {RouterConfig} from '../src/config'; import {recognize} from '../src/recognize'; @@ -11,7 +11,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA } - ], "a", s => { + ], "a", (s:RouterStateSnapshot) => { checkActivatedRoute(s.root, "", {}, RootComponent); checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA); }); @@ -22,7 +22,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA }, { path: 'b', component: ComponentB, outlet: 'left' }, { path: 'c', component: ComponentC, outlet: 'right' } - ], "a(left:b//right:c)", s => { + ], "a(left:b//right:c)", (s:RouterStateSnapshot) => { const c = s.children(s.root); checkActivatedRoute(c[0], "a", {}, ComponentA); checkActivatedRoute(c[1], "b", {}, ComponentB, 'left'); @@ -58,7 +58,7 @@ describe('recognize', () => { { path: '/a/b', component: ComponentA, children: [ {path: 'c', component: ComponentC} ] }, - ], url, "a/b/c").subscribe(s => { + ], url, "a/b/c").subscribe((s:RouterStateSnapshot) => { expect(s.root._urlSegment).toBe(url.root); expect(s.root._lastPathIndex).toBe(-1); @@ -76,7 +76,7 @@ describe('recognize', () => { checkRecognize([ {path: 'a', component: ComponentA, children: [{path: ':id', component: ComponentB}]}, {path: 'a/:id', component: ComponentC} - ], "a/paramA", s => { + ], "a/paramA", (s:RouterStateSnapshot) => { checkActivatedRoute(s.root, "", {}, RootComponent); checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "paramA", {id: 'paramA'}, ComponentB); @@ -85,7 +85,7 @@ describe('recognize', () => { checkRecognize([ {path: 'a', component: ComponentA}, {path: 'a/:id', component: ComponentC} - ], "a/paramA", s => { + ], "a/paramA", (s:RouterStateSnapshot) => { checkActivatedRoute(s.root, "", {}, RootComponent); checkActivatedRoute(s.firstChild(s.root), "a/paramA", {id: 'paramA'}, ComponentC); }); @@ -96,7 +96,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA }, { path: 'b', component: ComponentB, outlet: 'left' }, { path: 'b', component: ComponentC, outlet: 'right' } - ], "a(right:b)", s => { + ], "a(right:b)", (s:RouterStateSnapshot) => { const c = s.children(s.root); checkActivatedRoute(c[0], "a", {}, ComponentA); checkActivatedRoute(c[1], "b", {}, ComponentC, 'right'); @@ -108,7 +108,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA }, { path: 'b', component: ComponentB, outlet: 'left' }, { path: 'c', component: ComponentC, outlet: 'right' } - ], "a(left:b(right:c))", s => { + ], "a(left:b(right:c))", (s:RouterStateSnapshot) => { const c = s.children(s.root); checkActivatedRoute(c[0], "a", {}, ComponentA); checkActivatedRoute(c[1], "b", {}, ComponentB, 'left'); @@ -122,7 +122,7 @@ describe('recognize', () => { { path: 'b', component: ComponentB }, { path: 'c', component: ComponentC, outlet: 'left' } ] }, - ], "a/(b//left:c)", s => { + ], "a/(b//left:c)", (s:RouterStateSnapshot) => { const c = s.children(s.firstChild(s.root)); checkActivatedRoute(c[0], "b", {}, ComponentB, PRIMARY_OUTLET); checkActivatedRoute(c[1], "c", {}, ComponentC, 'left'); @@ -134,7 +134,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA }, { path: 'c', component: ComponentC, outlet: 'c' }, { path: 'b', component: ComponentB, outlet: 'b' } - ], "a(c:c//b:b)", s => { + ], "a(c:c//b:b)", (s:RouterStateSnapshot) => { const c = s.children(s.root); checkActivatedRoute(c[0], "a", {}, ComponentA); checkActivatedRoute(c[1], "b", {}, ComponentB, 'b'); @@ -150,7 +150,7 @@ describe('recognize', () => { ] }, { path: 'c', component: ComponentC, outlet: 'left' } - ], "a;a1=11;a2=22/b;b1=111;b2=222(left:c;c1=1111;c2=2222)", s => { + ], "a;a1=11;a2=22/b;b1=111;b2=222(left:c;c1=1111;c2=2222)", (s:RouterStateSnapshot) => { const c = s.children(s.root); checkActivatedRoute(c[0], "a", {a1: '11', a2: '22'}, ComponentA); checkActivatedRoute(s.firstChild(c[0]), "b", {b1: '111', b2: '222'}, ComponentB); @@ -162,7 +162,7 @@ describe('recognize', () => { it("should support root index routes", () => { checkRecognize([ {index: true, component: ComponentA} - ], "", s => { + ], "", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); }); }); @@ -170,7 +170,7 @@ describe('recognize', () => { it("should support nested root index routes", () => { checkRecognize([ {index: true, component: ComponentA, children: [{index: true, component: ComponentB}]} - ], "", s => { + ], "", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); }); @@ -181,7 +181,7 @@ describe('recognize', () => { {path: 'a', component: ComponentA, children: [ {index: true, component: ComponentB} ]} - ], "a", s => { + ], "a", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); }); @@ -197,7 +197,7 @@ describe('recognize', () => { } ] } - ], "c/10", s => { + ], "c/10", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); checkActivatedRoute( @@ -208,7 +208,7 @@ describe('recognize', () => { xit("should pass parameters to every nested index route (case with non-index route)", () => { checkRecognize([ {path: 'a', component: ComponentA, children: [{index: true, component: ComponentB}]} - ], "/a;a=1", s => { + ], "/a;a=1", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "a", {a: '1'}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {a: '1'}, ComponentB); }); @@ -219,7 +219,7 @@ describe('recognize', () => { it("should support root index routes", () => { recognize(RootComponent, [ {path: '', component: ComponentA} - ], tree(""), "").forEach(s => { + ], tree(""), "").forEach((s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); }); }); @@ -227,7 +227,7 @@ describe('recognize', () => { it("should support nested root index routes", () => { recognize(RootComponent, [ {path: '', component: ComponentA, children: [{path: '', component: ComponentB}]} - ], tree(""), "").forEach(s => { + ], tree(""), "").forEach((s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); }); @@ -237,7 +237,7 @@ describe('recognize', () => { const url = tree(""); recognize(RootComponent, [ {path: '', component: ComponentA, children: [{path: '', component: ComponentB}]} - ], url, "").forEach(s => { + ], url, "").forEach((s:RouterStateSnapshot) => { expect(s.root._urlSegment).toBe(url.root); expect(s.root._lastPathIndex).toBe(-1); @@ -256,7 +256,7 @@ describe('recognize', () => { {path: 'a', component: ComponentA, children: [ {path: '', component: ComponentB} ]} - ], tree("a"), "a").forEach(s => { + ], tree("a"), "a").forEach((s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "a", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); }); @@ -272,7 +272,7 @@ describe('recognize', () => { } ] } - ], tree("c/10"), "c/10").forEach(s => { + ], tree("c/10"), "c/10").forEach((s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "", {}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {}, ComponentB); checkActivatedRoute( @@ -283,7 +283,7 @@ describe('recognize', () => { xit("should pass parameters to every nested index route (case with non-index route)", () => { recognize(RootComponent, [ {path: 'a', component: ComponentA, children: [{path: '', component: ComponentB}]} - ], tree("/a;a=1"), "/a;a=1").forEach(s => { + ], tree("/a;a=1"), "/a;a=1").forEach((s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "a", {a: '1'}, ComponentA); checkActivatedRoute(s.firstChild(s.firstChild(s.root)), "", {a: '1'}, ComponentB); }); @@ -294,7 +294,7 @@ describe('recognize', () => { it("should support simple wildcards", () => { checkRecognize([ {path: '**', component: ComponentA} - ], "a/b/c/d;a1=11", s => { + ], "a/b/c/d;a1=11", (s:RouterStateSnapshot) => { checkActivatedRoute(s.firstChild(s.root), "a/b/c/d", {a1:'11'}, ComponentA); }); }); @@ -303,7 +303,7 @@ describe('recognize', () => { describe("query parameters", () => { it("should support query params", () => { const config = [{path: 'a', component: ComponentA}]; - checkRecognize(config, "a?q=11", s => { + checkRecognize(config, "a?q=11", (s:RouterStateSnapshot) => { expect(s.queryParams).toEqual({q: '11'}); }); }); @@ -312,7 +312,7 @@ describe('recognize', () => { describe("fragment", () => { it("should support fragment", () => { const config = [{path: 'a', component: ComponentA}]; - checkRecognize(config, "a#f1", s => { + checkRecognize(config, "a#f1", (s:RouterStateSnapshot) => { expect(s.fragment).toEqual("f1"); }); }); @@ -324,7 +324,7 @@ describe('recognize', () => { { path: 'a', component: ComponentA }, { path: 'b', component: ComponentB, outlet: 'aux' }, { path: 'c', component: ComponentC, outlet: 'aux' } - ], tree("a(aux:b//aux:c)"), "a(aux:b//aux:c)").subscribe((_) => {}, s => { + ], tree("a(aux:b//aux:c)"), "a(aux:b//aux:c)").subscribe((_) => {}, (s:RouterStateSnapshot) => { expect(s.toString()).toContain("Two segments cannot have the same outlet name: 'aux:b' and 'aux:c'."); }); }); @@ -332,7 +332,7 @@ describe('recognize', () => { it("should error when no matching routes", () => { recognize(RootComponent, [ { path: 'a', component: ComponentA } - ], tree("invalid"), "invalid").subscribe((_) => {}, s => { + ], tree("invalid"), "invalid").subscribe((_) => {}, (s:RouterStateSnapshot) => { expect(s.toString()).toContain("Cannot match any routes"); }); }); @@ -340,7 +340,7 @@ describe('recognize', () => { it("should error when no matching routes (too short)", () => { recognize(RootComponent, [ { path: 'a/:id', component: ComponentA } - ], tree("a"), "a").subscribe((_) => {}, s => { + ], tree("a"), "a").subscribe((_) => {}, (s:RouterStateSnapshot) => { expect(s.toString()).toContain("Cannot match any routes"); }); }); diff --git a/modules/@angular/router/test/router.spec.ts b/modules/@angular/router/test/router.spec.ts index 13f2b23fcd..3c2b93674b 100644 --- a/modules/@angular/router/test/router.spec.ts +++ b/modules/@angular/router/test/router.spec.ts @@ -16,6 +16,7 @@ import { import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing'; import { ComponentResolver } from '@angular/core'; +import { Location } from '@angular/common'; import { SpyLocation } from '@angular/common/testing'; import { UrlSerializer, DefaultUrlSerializer, RouterOutletMap, Router, ActivatedRoute, ROUTER_DIRECTIVES, Params, RouterStateSnapshot, ActivatedRouteSnapshot, CanActivate, CanDeactivate, Event, NavigationStart, NavigationEnd, NavigationCancel, NavigationError, RoutesRecognized, RouterConfig } from '../src/index'; @@ -37,19 +38,19 @@ describe("Integration", () => { {provide: Location, useClass: SpyLocation}, { provide: Router, - useFactory: (resolver, urlSerializer, outletMap, location, injector) => { + useFactory: (resolver:ComponentResolver, urlSerializer:UrlSerializer, outletMap:RouterOutletMap, location:Location, injector:Injector) => { const r = new Router(RootCmp, resolver, urlSerializer, outletMap, location, injector, config); r.initialNavigation(); return r; }, deps: [ComponentResolver, UrlSerializer, RouterOutletMap, Location, Injector] }, - {provide: ActivatedRoute, useFactory: (r) => r.routerState.root, deps: [Router]}, + {provide: ActivatedRoute, useFactory: (r:Router) => r.routerState.root, deps: [Router]}, ]; }); it('should navigate with a provided config', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -61,7 +62,7 @@ describe("Integration", () => { it('should update location when navigating', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -80,7 +81,7 @@ describe("Integration", () => { }))); it('should navigate back and forward', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -109,7 +110,7 @@ describe("Integration", () => { }))); it('should navigate when locations changes', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -122,14 +123,14 @@ describe("Integration", () => { router.navigateByUrl('/team/22/user/victor'); advance(fixture); - location.simulateHashChange("/team/22/user/fedor"); + (location).simulateHashChange("/team/22/user/fedor"); advance(fixture); expect(fixture.debugElement.nativeElement).toHaveText('team 22 { user fedor, right: }'); }))); it('should update the location when the matched route does not change', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -149,7 +150,7 @@ describe("Integration", () => { }))); it('should support secondary routes', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -168,7 +169,7 @@ describe("Integration", () => { }))); it('should deactivate outlets', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -189,7 +190,7 @@ describe("Integration", () => { }))); it('should deactivate nested outlets', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -211,7 +212,7 @@ describe("Integration", () => { }))); it('should set query params and fragment', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -229,7 +230,7 @@ describe("Integration", () => { }))); it('should push params only when they change', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -255,7 +256,7 @@ describe("Integration", () => { }))); it('should work when navigating to /', - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -276,7 +277,7 @@ describe("Integration", () => { }))); it("should cancel in-flight navigations", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -284,7 +285,7 @@ describe("Integration", () => { { path: '/user/:name', component: UserCmp } ]); - const recordedEvents = []; + const recordedEvents:any = []; router.events.forEach(e => recordedEvents.push(e)); router.navigateByUrl('/user/init'); @@ -292,7 +293,7 @@ describe("Integration", () => { const user = fixture.debugElement.children[1].componentInstance; - let r1, r2; + let r1:any, r2:any; router.navigateByUrl('/user/victor').then(_ => r1 = _); router.navigateByUrl('/user/fedor').then(_ => r2 = _); advance(fixture); @@ -318,7 +319,7 @@ describe("Integration", () => { }))); it("should handle failed navigations gracefully", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb:TestComponentBuilder) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -326,10 +327,10 @@ describe("Integration", () => { { path: '/user/:name', component: UserCmp } ]); - const recordedEvents = []; + const recordedEvents:any = []; router.events.forEach(e => recordedEvents.push(e)); - let e; + let e:any; router.navigateByUrl('/invalid').catch(_ => e = _); advance(fixture); expect(e.message).toContain("Cannot match any routes"); @@ -350,7 +351,7 @@ describe("Integration", () => { }))); it('should replace state when path is equal to current path', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -377,7 +378,7 @@ describe("Integration", () => { describe("router links", () => { it("should support string router links", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -401,7 +402,7 @@ describe("Integration", () => { }))); it("should support absolute router links", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -425,7 +426,7 @@ describe("Integration", () => { }))); it("should support relative router links", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -451,7 +452,7 @@ describe("Integration", () => { }))); it("should support top-level link", - fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + fakeAsync(inject([Router, TestComponentBuilder], (router:Router, tcb:TestComponentBuilder) => { let fixture = tcb.createFakeAsync(AbsoluteLinkCmp); advance(fixture); @@ -459,7 +460,7 @@ describe("Integration", () => { }))); it("should support query params and fragments", - fakeAsync(inject([Router, Location, TestComponentBuilder], (router, location, tcb) => { + fakeAsync(inject([Router, Location, TestComponentBuilder], (router:Router, location:Location, tcb:TestComponentBuilder) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -486,7 +487,7 @@ describe("Integration", () => { }); describe("redirects", () => { - it("should work", fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + it("should work", fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -506,11 +507,11 @@ describe("Integration", () => { describe("CanActivate", () => { describe("should not activate a route when CanActivate returns false", () => { beforeEachProviders(() => [ - {provide: 'alwaysFalse', useValue: (a, b) => false} + {provide: 'alwaysFalse', useValue: (a:any, b:any) => false} ]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -531,7 +532,7 @@ describe("Integration", () => { ]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -556,7 +557,7 @@ describe("Integration", () => { beforeEachProviders(() => [AlwaysTrue]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -579,7 +580,7 @@ describe("Integration", () => { ]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -607,7 +608,7 @@ describe("Integration", () => { it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -632,7 +633,7 @@ describe("Integration", () => { }))); it('works with a nested route', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -671,7 +672,7 @@ describe("Integration", () => { beforeEachProviders(() => [AlwaysTrue]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -698,7 +699,7 @@ describe("Integration", () => { ]); it('works', - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -719,7 +720,7 @@ describe("Integration", () => { describe("routerActiveLink", () => { it("should set the class when the link is active (exact = true)", - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -746,7 +747,7 @@ describe("Integration", () => { }))); it("should set the class on a parent element when the link is active (exact = true)", - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); @@ -773,7 +774,7 @@ describe("Integration", () => { }))); it("should set the class when the link is active (exact = false)", - fakeAsync(inject([Router, TestComponentBuilder, Location], (router, tcb, location) => { + fakeAsync(inject([Router, TestComponentBuilder, Location], (router:Router, tcb:TestComponentBuilder, location:Location) => { const fixture = tcb.createFakeAsync(RootCmp); advance(fixture); diff --git a/modules/@angular/router/tsconfig.json b/modules/@angular/router/tsconfig.json index e5bcb31670..2bae4f5a11 100644 --- a/modules/@angular/router/tsconfig.json +++ b/modules/@angular/router/tsconfig.json @@ -5,7 +5,8 @@ "noEmitOnError": false, "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "noImplicitAny": true, + "noImplicitReturns": true, "outDir": "dist", "rootDir": ".", "inlineSourceMap": true, diff --git a/modules/@angular/router/tsconfig.publish.es5.json b/modules/@angular/router/tsconfig.publish.es5.json index 8b2dcaa486..67cb080030 100644 --- a/modules/@angular/router/tsconfig.publish.es5.json +++ b/modules/@angular/router/tsconfig.publish.es5.json @@ -4,7 +4,8 @@ "emitDecoratorMetadata": true, "module": "commonjs", "target": "es5", - "noImplicitAny": false, + "noImplicitAny": true, + "noImplicitReturns": true, "outDir": "dist", "rootDir": "src", "inlineSourceMap": true, diff --git a/modules/@angular/router/tsconfig.publish.esm.json b/modules/@angular/router/tsconfig.publish.esm.json index d957ce0b95..d3a4de9c90 100644 --- a/modules/@angular/router/tsconfig.publish.esm.json +++ b/modules/@angular/router/tsconfig.publish.esm.json @@ -3,7 +3,8 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "target": "es6", - "noImplicitAny": false, + "noImplicitAny": true, + "noImplicitReturns": true, "outDir": "dist/esm", "rootDir": "src", "inlineSourceMap": true,