diff --git a/modules/@angular/router/package.json b/modules/@angular/router/package.json index 3446fd2310..d6f8721de0 100644 --- a/modules/@angular/router/package.json +++ b/modules/@angular/router/package.json @@ -63,7 +63,7 @@ "systemjs-builder": "^0.15.7", "traceur": "0.0.96", "tsd": "^0.6.5", - "typescript": "^1.9.0-dev.20160409", + "typescript": "^1.8.10", "typings": "^1.0.4", "zone.js": "^0.6.6", "clang-format": "^1.0.35", diff --git a/modules/@angular/router/src/apply_redirects.ts b/modules/@angular/router/src/apply_redirects.ts index 813dddfa25..bb521eef91 100644 --- a/modules/@angular/router/src/apply_redirects.ts +++ b/modules/@angular/router/src/apply_redirects.ts @@ -94,7 +94,8 @@ function expandRegularPathWithParamsAgainstRouteUsingRedirect( segment: UrlSegment, routes: Route[], route: Route, paths: UrlPathWithParams[], outlet: string): UrlSegment { const {consumedPaths, lastChild, positionalParamSegments} = match(segment, route, paths); - const newPaths = applyRedirectCommands(consumedPaths, route.redirectTo, positionalParamSegments); + const newPaths = + applyRedirectCommands(consumedPaths, route.redirectTo, positionalParamSegments); if (route.redirectTo.startsWith('/')) { throw new GlobalRedirect(newPaths); } else { diff --git a/modules/@angular/router/src/create_url_tree.ts b/modules/@angular/router/src/create_url_tree.ts index 941d2fc64f..88ad1dd72d 100644 --- a/modules/@angular/router/src/create_url_tree.ts +++ b/modules/@angular/router/src/create_url_tree.ts @@ -4,8 +4,8 @@ import {UrlPathWithParams, UrlSegment, UrlTree} from './url_tree'; import {forEach, shallowEqual} from './utils/collection'; export function createUrlTree( - route: ActivatedRoute, urlTree: UrlTree, commands: any[], queryParams: Params | undefined, - fragment: string | undefined): UrlTree { + route: ActivatedRoute, urlTree: UrlTree, commands: any[], queryParams: Params, + fragment: string): UrlTree { if (commands.length === 0) { return tree(urlTree.root, urlTree.root, urlTree, queryParams, fragment); } @@ -24,8 +24,8 @@ export function createUrlTree( } function tree( - oldSegment: UrlSegment, newSegment: UrlSegment, urlTree: UrlTree, - queryParams: Params | undefined, fragment: string | undefined): UrlTree { + oldSegment: UrlSegment, newSegment: UrlSegment, urlTree: UrlTree, queryParams: Params, + fragment: string): UrlTree { const q = queryParams ? stringify(queryParams) : urlTree.queryParams; const f = fragment ? fragment : urlTree.fragment; @@ -38,7 +38,7 @@ function tree( function replaceSegment( current: UrlSegment, oldSegment: UrlSegment, newSegment: UrlSegment): UrlSegment { - const children = {}; + const children: {[key: string]: UrlSegment} = {}; forEach(current.children, (c, k) => { if (c === oldSegment) { children[k] = newSegment; @@ -162,7 +162,7 @@ function updateSegmentChildren( return new UrlSegment(segment.pathsWithParams, {}); } else { const outlet = getOutlet(commands); - const children = {}; + const children: {[key: string]: UrlSegment} = {}; children[outlet] = updateSegment(segment.children[outlet], startIndex, commands); forEach(segment.children, (child, childOutlet) => { if (childOutlet !== outlet) { @@ -223,7 +223,7 @@ function createNewSegment(segment: UrlSegment, startIndex: number, commands: any } function stringify(params: {[key: string]: any}): {[key: string]: string} { - const res = {}; + const res: {[key: string]: string} = {}; forEach(params, (v, k) => res[k] = `${v}`); return res; } diff --git a/modules/@angular/router/src/directives/router_outlet.ts b/modules/@angular/router/src/directives/router_outlet.ts index 0e57f288a9..ca701390b7 100644 --- a/modules/@angular/router/src/directives/router_outlet.ts +++ b/modules/@angular/router/src/directives/router_outlet.ts @@ -5,8 +5,8 @@ import {PRIMARY_OUTLET} from '../shared'; @Directive({selector: 'router-outlet'}) export class RouterOutlet { - private activated: ComponentRef|null; - private _activatedRoute: ActivatedRoute|null; + private activated: ComponentRef; + private _activatedRoute: ActivatedRoute; public outletMap: RouterOutletMap; /** diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index cfed27e04b..3081f9f05a 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -118,7 +118,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 = {}; + const posParameters: {[key: string]: any} = {}; const consumedPaths = []; let currentIndex = 0; @@ -142,7 +142,7 @@ function match(segment: UrlSegment, route: Route, paths: UrlPathWithParams[]) { throw new NoMatch(); } - const parameters = merge(posParameters, consumedPaths[consumedPaths.length - 1].parameters); + const parameters = merge(posParameters, consumedPaths[consumedPaths.length - 1].parameters); return {consumedPaths, lastChild: currentIndex, parameters}; } diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index 402c4e0e56..fb2ee6f640 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -352,9 +352,9 @@ class GuardChecks { } private traverseChildRoutes( - futureNode: TreeNode, currNode: TreeNode|null, - outletMap: RouterOutletMap|null): void { - const prevChildren = nodeChildrenAsMap(currNode); + futureNode: TreeNode, currNode: TreeNode, + outletMap: RouterOutletMap): void { + const prevChildren: {[key: string]: any} = nodeChildrenAsMap(currNode); futureNode.children.forEach(c => { this.traverseRoutes(c, prevChildren[c.value.outlet], outletMap); delete prevChildren[c.value.outlet]; @@ -363,8 +363,8 @@ class GuardChecks { } traverseRoutes( - futureNode: TreeNode, currNode: TreeNode|null, - parentOutletMap: RouterOutletMap|null): void { + futureNode: TreeNode, currNode: TreeNode, + parentOutletMap: RouterOutletMap): void { const future = futureNode.value; const curr = currNode ? currNode.value : null; const outlet = parentOutletMap ? parentOutletMap._outlets[futureNode.value.outlet] : null; @@ -445,9 +445,9 @@ class ActivateRoutes { } private activateChildRoutes( - futureNode: TreeNode, currNode: TreeNode|null, + futureNode: TreeNode, currNode: TreeNode, outletMap: RouterOutletMap): void { - const prevChildren = nodeChildrenAsMap(currNode); + const prevChildren: {[key: string]: any} = nodeChildrenAsMap(currNode); futureNode.children.forEach(c => { this.activateRoutes(c, prevChildren[c.value.outlet], outletMap); delete prevChildren[c.value.outlet]; @@ -456,7 +456,7 @@ class ActivateRoutes { } activateRoutes( - futureNode: TreeNode, currNode: TreeNode|null, + futureNode: TreeNode, currNode: TreeNode, parentOutletMap: RouterOutletMap): void { const future = futureNode.value; const curr = currNode ? currNode.value : null; @@ -502,7 +502,7 @@ function pushQueryParamsAndFragment(state: RouterState): void { } } -function nodeChildrenAsMap(node: TreeNode| null) { +function nodeChildrenAsMap(node: TreeNode) { return node ? node.children.reduce((m, c) => { m[c.value.outlet] = c; return m; diff --git a/modules/@angular/router/src/router_state.ts b/modules/@angular/router/src/router_state.ts index 2c9a6a0b4f..1425eea546 100644 --- a/modules/@angular/router/src/router_state.ts +++ b/modules/@angular/router/src/router_state.ts @@ -115,7 +115,7 @@ export class ActivatedRouteSnapshot { _resolvedComponentFactory: ComponentFactory; /** @internal **/ - _routeConfig: Route|null; + _routeConfig: Route; /** @internal **/ _urlSegment: UrlSegment; @@ -127,7 +127,7 @@ export class ActivatedRouteSnapshot { */ constructor( public url: UrlPathWithParams[], public params: Params, public outlet: string, - public component: Type|string, routeConfig: Route|null, urlSegment: UrlSegment, + public component: Type|string, routeConfig: Route, urlSegment: UrlSegment, lastPathIndex: number) { this._routeConfig = routeConfig; this._urlSegment = urlSegment; @@ -160,7 +160,7 @@ export class RouterStateSnapshot extends Tree { */ constructor( public url: string, root: TreeNode, public queryParams: Params, - public fragment: string|null) { + public fragment: string) { super(root); } diff --git a/modules/@angular/router/src/url_serializer.ts b/modules/@angular/router/src/url_serializer.ts index 311485a180..e0fa42635c 100644 --- a/modules/@angular/router/src/url_serializer.ts +++ b/modules/@angular/router/src/url_serializer.ts @@ -162,7 +162,7 @@ class UrlParser { paths.push(this.parsePathWithParams()); } - let children = {}; + let children: {[key: string]: UrlSegment} = {}; if (this.peekStartsWith('/(')) { this.capture('/'); children = this.parseParens(true); @@ -200,7 +200,7 @@ class UrlParser { return params; } - parseFragment(): string|null { + parseFragment(): string { if (this.peekStartsWith('#')) { return this.remaining.substring(1); } else { @@ -255,7 +255,7 @@ class UrlParser { } parseParens(allowPrimary: boolean): {[key: string]: UrlSegment} { - const segments = {}; + const segments: {[key: string]: UrlSegment} = {}; this.capture('('); while (!this.peekStartsWith(')') && this.remaining.length > 0) { diff --git a/modules/@angular/router/src/url_tree.ts b/modules/@angular/router/src/url_tree.ts index cc981f6fab..1e5e9840d3 100644 --- a/modules/@angular/router/src/url_tree.ts +++ b/modules/@angular/router/src/url_tree.ts @@ -15,13 +15,13 @@ export class UrlTree { */ constructor( public root: UrlSegment, public queryParams: {[key: string]: string}, - public fragment: string|null) {} + public fragment: string) {} toString(): string { return new DefaultUrlSerializer().serialize(this); } } export class UrlSegment { - public parent: UrlSegment|null = null; + public parent: UrlSegment = null; constructor( public pathsWithParams: UrlPathWithParams[], public children: {[key: string]: UrlSegment}) { forEach(children, (v, k) => v.parent = this); @@ -46,7 +46,7 @@ export function equalPathsWithParams(a: UrlPathWithParams[], b: UrlPathWithParam export function mapChildren(segment: UrlSegment, fn: (v: UrlSegment, k: string) => UrlSegment): {[name: string]: UrlSegment} { - const newChildren = {}; + const newChildren: {[name: string]: UrlSegment} = {}; forEach(segment.children, (child, childOutlet) => { if (childOutlet === PRIMARY_OUTLET) { newChildren[childOutlet] = fn(child, childOutlet); diff --git a/modules/@angular/router/src/utils/collection.ts b/modules/@angular/router/src/utils/collection.ts index 460ea0646a..1dd0e16b67 100644 --- a/modules/@angular/router/src/utils/collection.ts +++ b/modules/@angular/router/src/utils/collection.ts @@ -24,11 +24,11 @@ export function flatten(a: T[][]): T[] { return target; } -export function first(a: T[]): T|null { +export function first(a: T[]): T { return a.length > 0 ? a[0] : null; } -export function last(a: T[]): T|null { +export function last(a: T[]): T { return a.length > 0 ? a[a.length - 1] : null; } diff --git a/modules/@angular/router/src/utils/tree.ts b/modules/@angular/router/src/utils/tree.ts index a508c1f56f..b41bdaa81a 100644 --- a/modules/@angular/router/src/utils/tree.ts +++ b/modules/@angular/router/src/utils/tree.ts @@ -6,7 +6,7 @@ export class Tree { get root(): T { return this._root.value; } - parent(t: T): T|null { + parent(t: T): T { const p = this.pathFromRoot(t); return p.length > 1 ? p[p.length - 2] : null; } @@ -16,7 +16,7 @@ export class Tree { return n ? n.children.map(t => t.value) : []; } - firstChild(t: T): T|null { + firstChild(t: T): T { const n = findNode(t, this._root); return n && n.children.length > 0 ? n.children[0].value : null; } @@ -34,7 +34,7 @@ export class Tree { contains(tree: Tree): boolean { return contains(this._root, tree._root); } } -function findNode(expected: T, c: TreeNode): TreeNode|null { +function findNode(expected: T, c: TreeNode): TreeNode { if (expected === c.value) return c; for (let cc of c.children) { const r = findNode(expected, cc); diff --git a/modules/@angular/router/test/create_router_state.spec.ts b/modules/@angular/router/test/create_router_state.spec.ts index c2d1a16ec1..0079dc33ce 100644 --- a/modules/@angular/router/test/create_router_state.spec.ts +++ b/modules/@angular/router/test/create_router_state.spec.ts @@ -61,7 +61,7 @@ function createState(config: RouterConfig, url: string): RouterStateSnapshot { return res; } -function checkActivatedRoute(actual: ActivatedRoute | null, cmp: Function, outlet: string = PRIMARY_OUTLET):void { +function checkActivatedRoute(actual: ActivatedRoute, cmp: Function, outlet: string = PRIMARY_OUTLET):void { if (actual === null) { expect(actual).toBeDefined(); } else { diff --git a/modules/@angular/router/test/recognize.spec.ts b/modules/@angular/router/test/recognize.spec.ts index 6fdfcf660b..b585cc047b 100644 --- a/modules/@angular/router/test/recognize.spec.ts +++ b/modules/@angular/router/test/recognize.spec.ts @@ -353,7 +353,7 @@ function checkRecognize(config: RouterConfig, url: string, callback: any): void }); } -function checkActivatedRoute(actual: ActivatedRouteSnapshot | null, url: string, params: Params, cmp: Function, outlet: string = PRIMARY_OUTLET):void { +function checkActivatedRoute(actual: ActivatedRouteSnapshot, url: string, params: Params, cmp: Function, outlet: string = PRIMARY_OUTLET):void { if (actual === null) { expect(actual).not.toBeNull(); } else {