Revert "fix(router): Update types for TypeScript nullability support"

This reverts commit 56c46d70f7.

Broke in G3.
This commit is contained in:
Tobias Bosch
2017-04-17 09:47:59 -07:00
parent 6d930d2fc5
commit ea8ffc9841
26 changed files with 223 additions and 230 deletions

View File

@ -45,7 +45,7 @@ export function flatten<T>(arr: T[][]): T[] {
return Array.prototype.concat.apply([], arr);
}
export function last<T>(a: T[]): T|null {
export function last<T>(a: T[]): T {
return a.length > 0 ? a[a.length - 1] : null;
}

View File

@ -17,7 +17,7 @@ export class Tree<T> {
/**
* @internal
*/
parent(t: T): T|null {
parent(t: T): T {
const p = this.pathFromRoot(t);
return p.length > 1 ? p[p.length - 2] : null;
}
@ -33,7 +33,7 @@ export class Tree<T> {
/**
* @internal
*/
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;
}
@ -55,7 +55,7 @@ export class Tree<T> {
pathFromRoot(t: T): T[] { return findPath(t, this._root, []).map(s => s.value); }
}
function findNode<T>(expected: T, c: TreeNode<T>): TreeNode<T>|null {
function findNode<T>(expected: T, c: TreeNode<T>): TreeNode<T> {
if (expected === c.value) return c;
for (const cc of c.children) {
const r = findNode(expected, cc);