refactor(TypeScript): Add noImplicitAny

We automatically insert explicit 'any's where needed. These need to be
addressed as in #9100.

Fixes #4924
This commit is contained in:
ScottSWu
2016-06-08 15:45:15 -07:00
parent 87d824e1b4
commit 86fbd50c3d
305 changed files with 2338 additions and 2337 deletions

View File

@ -155,7 +155,7 @@ export class RouterOutlet implements OnDestroy {
* or resolves to true if the hook is not present.
*/
routerCanReuse(nextInstruction: ComponentInstruction): Promise<boolean> {
var result;
var result: any /** TODO #9100 */;
if (isBlank(this._currentInstruction) ||
this._currentInstruction.componentType != nextInstruction.componentType) {

View File

@ -197,7 +197,7 @@ export abstract class Instruction {
/** @internal */
_stringifyAux(): string {
var routes = [];
var routes: any[] /** TODO #9100 */ = [];
StringMapWrapper.forEach(this.auxInstruction, (auxInstruction: Instruction, _: string) => {
routes.push(auxInstruction._stringifyPathMatrixAux());
});
@ -310,7 +310,7 @@ export class ComponentInstruction {
* @internal
*/
constructor(public urlPath: string, public urlParams: string[], data: RouteData,
public componentType, public terminal: boolean, public specificity: string,
public componentType: any /** TODO #9100 */, public terminal: boolean, public specificity: string,
public params: {[key: string]: string} = null, public routeName: string) {
this.routeData = isPresent(data) ? data : BLANK_ROUTE_DATA;
}

View File

@ -2,12 +2,12 @@ import {Type} from '@angular/core';
import {RouteLifecycleHook, CanActivate} from './lifecycle_annotations_impl';
import {reflector} from '../../core_private';
export function hasLifecycleHook(e: RouteLifecycleHook, type): boolean {
export function hasLifecycleHook(e: RouteLifecycleHook, type: any /** TODO #9100 */): boolean {
if (!(type instanceof Type)) return false;
return e.name in(<any>type).prototype;
}
export function getCanActivateHook(type): Function {
export function getCanActivateHook(type: any /** TODO #9100 */): Function {
var annotations = reflector.annotations(type);
for (let i = 0; i < annotations.length; i += 1) {
let annotation = annotations[i];

View File

@ -90,7 +90,7 @@ export function normalizeRouteConfig(config: RouteDefinition,
function wrapLoaderToReconfigureRegistry(loader: Function, registry: RouteRegistry): () =>
Promise<Type> {
return () => {
return loader().then((componentType) => {
return loader().then((componentType: any /** TODO #9100 */) => {
registry.configFromComponent(componentType);
return componentType;
});

View File

@ -236,7 +236,7 @@ export class RouteRegistry {
*/
generate(linkParams: any[], ancestorInstructions: Instruction[], _aux = false): Instruction {
var params = splitAndFlattenLinkParams(linkParams);
var prevInstruction;
var prevInstruction: any /** TODO #9100 */;
// The first segment should be either '.' (generate from parent) or '' (generate from root).
// When we normalize above, we strip all the slashes, './' becomes '.' and '/' becomes ''.
@ -264,7 +264,7 @@ export class RouteRegistry {
// we must only peak at the link param, and not consume it
let routeName = ListWrapper.first(params);
let parentComponentType = this._rootComponent;
let grandparentComponentType = null;
let grandparentComponentType: any /** TODO #9100 */ = null;
if (ancestorInstructions.length > 1) {
let parentComponentInstruction = ancestorInstructions[ancestorInstructions.length - 1];
@ -333,7 +333,7 @@ export class RouteRegistry {
private _generate(linkParams: any[], ancestorInstructions: Instruction[],
prevInstruction: Instruction, _aux = false, _originalLink: any[]): Instruction {
let parentComponentType = this._rootComponent;
let componentInstruction = null;
let componentInstruction: any /** TODO #9100 */ = null;
let auxInstructions: {[key: string]: Instruction} = {};
let parentInstruction: Instruction = ListWrapper.last(ancestorInstructions);
@ -456,7 +456,7 @@ export class RouteRegistry {
return null;
}
var defaultChild = null;
var defaultChild: any /** TODO #9100 */ = null;
if (isPresent(rules.defaultRule.handler.componentType)) {
var componentInstruction = rules.defaultRule.generate({});
if (!rules.defaultRule.terminal) {
@ -477,7 +477,7 @@ export class RouteRegistry {
* Returns: ['', 'a', 'b', {c: 2}]
*/
function splitAndFlattenLinkParams(linkParams: any[]): any[] {
var accumulation = [];
var accumulation: any[] /** TODO #9100 */ = [];
linkParams.forEach(function(item: any) {
if (isString(item)) {
var strItem: string = <string>item;
@ -529,7 +529,7 @@ function compareSpecificityStrings(a: string, b: string): number {
return a.length - b.length;
}
function assertTerminalComponent(component, path) {
function assertTerminalComponent(component: any /** TODO #9100 */, path: any /** TODO #9100 */) {
if (!isType(component)) {
return;
}

View File

@ -116,7 +116,7 @@ export class Router {
this._auxRouters.set(outletName, router);
router._outlet = outlet;
var auxInstruction;
var auxInstruction: any /** TODO #9100 */;
if (isPresent(this.currentInstruction) &&
isPresent(auxInstruction = this.currentInstruction.auxInstruction[outletName])) {
return router.commit(auxInstruction);
@ -152,7 +152,7 @@ export class Router {
return false;
}
if (isPresent(instruction.component.params)) {
StringMapWrapper.forEach(instruction.component.params, (value, key) => {
StringMapWrapper.forEach(instruction.component.params, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => {
if (currentInstruction.component.params[key] !== value) {
reason = false;
}
@ -254,7 +254,7 @@ export class Router {
unsettledInstructions.push(this._settleInstruction(instruction.child));
}
StringMapWrapper.forEach(instruction.auxInstruction, (instruction: Instruction, _) => {
StringMapWrapper.forEach(instruction.auxInstruction, (instruction: Instruction, _: any /** TODO #9100 */) => {
unsettledInstructions.push(this._settleInstruction(instruction));
});
return PromiseWrapper.all(unsettledInstructions);
@ -547,7 +547,7 @@ export class RootRouter extends Router {
}
class ChildRouter extends Router {
constructor(parent: Router, hostComponent) {
constructor(parent: Router, hostComponent: any /** TODO #9100 */) {
super(parent.registry, parent, hostComponent, parent.root);
this.parent = parent;
}

View File

@ -119,7 +119,7 @@ export class ParamRoutePath implements RoutePath {
if (isPresent(currentUrlSegment)) {
// the star segment consumes all of the remaining URL, including matrix params
if (pathSegment instanceof StarPathSegment) {
positionalParams[pathSegment.name] = currentUrlSegment.toString();
(positionalParams as any /** TODO #9100 */)[pathSegment.name] = currentUrlSegment.toString();
captured.push(currentUrlSegment.toString());
nextUrlSegment = null;
break;
@ -128,7 +128,7 @@ export class ParamRoutePath implements RoutePath {
captured.push(currentUrlSegment.path);
if (pathSegment instanceof DynamicPathSegment) {
positionalParams[pathSegment.name] = decodeDynamicSegment(currentUrlSegment.path);
(positionalParams as any /** TODO #9100 */)[pathSegment.name] = decodeDynamicSegment(currentUrlSegment.path);
} else if (!pathSegment.match(currentUrlSegment.path)) {
return null;
}
@ -145,8 +145,8 @@ export class ParamRoutePath implements RoutePath {
var urlPath = captured.join('/');
var auxiliary = [];
var urlParams = [];
var auxiliary: any[] /** TODO #9100 */ = [];
var urlParams: any[] /** TODO #9100 */ = [];
var allParams = positionalParams;
if (isPresent(currentUrlSegment)) {
// If this is the root component, read query params. Otherwise, read matrix params.
@ -168,7 +168,7 @@ export class ParamRoutePath implements RoutePath {
generateUrl(params: {[key: string]: any}): GeneratedUrl {
var paramTokens = new TouchMap(params);
var path = [];
var path: any[] /** TODO #9100 */ = [];
for (var i = 0; i < this._segments.length; i++) {
let segment = this._segments[i];
@ -199,7 +199,7 @@ export class ParamRoutePath implements RoutePath {
var limit = segmentStrings.length - 1;
for (var i = 0; i <= limit; i++) {
var segment = segmentStrings[i], match;
var segment = segmentStrings[i], match: any /** TODO #9100 */;
if (isPresent(match = RegExpWrapper.firstMatch(DynamicPathSegment.paramMatcher, segment))) {
this._segments.push(new DynamicPathSegment(match[1]));
@ -230,7 +230,7 @@ export class ParamRoutePath implements RoutePath {
// The code below uses place values to combine the different types of segments into a single
// string that we can sort later. Each static segment is marked as a specificity of "2," each
// dynamic segment is worth "1" specificity, and stars are worth "0" specificity.
var i, length = this._segments.length, specificity;
var i: any /** TODO #9100 */, length = this._segments.length, specificity: any /** TODO #9100 */;
if (length == 0) {
// a single slash (or "empty segment" is as specific as a static segment
specificity += '2';
@ -246,8 +246,8 @@ export class ParamRoutePath implements RoutePath {
private _calculateHash(): string {
// this function is used to determine whether a route config path like `/foo/:id` collides with
// `/foo/:name`
var i, length = this._segments.length;
var hashParts = [];
var i: any /** TODO #9100 */, length = this._segments.length;
var hashParts: any[] /** TODO #9100 */ = [];
for (i = 0; i < length; i++) {
hashParts.push(this._segments[i].hash);
}

View File

@ -44,7 +44,7 @@ export class RuleSet {
* @returns {boolean} true if the config is terminal
*/
config(config: RouteDefinition): boolean {
let handler;
let handler: any /** TODO #9100 */;
if (isPresent(config.name) && config.name[0].toUpperCase() != config.name[0]) {
let suggestedName = config.name[0].toUpperCase() + config.name.substring(1);
@ -104,7 +104,7 @@ export class RuleSet {
* Given a URL, returns a list of `RouteMatch`es, which are partial recognitions for some route.
*/
recognize(urlParse: Url): Promise<RouteMatch>[] {
var solutions = [];
var solutions: any[] /** TODO #9100 */ = [];
this.rules.forEach((routeRecognizer: AbstractRule) => {
var pathMatch = routeRecognizer.recognize(urlParse);
@ -157,7 +157,7 @@ export class RuleSet {
return rule.generate(params);
}
private _assertNoHashCollision(hash: string, path) {
private _assertNoHashCollision(hash: string, path: any /** TODO #9100 */) {
this.rules.forEach((rule) => {
if (hash == rule.hash) {
throw new BaseException(

View File

@ -19,7 +19,7 @@ export class PathMatch extends RouteMatch {
}
export class RedirectMatch extends RouteMatch {
constructor(public redirectTo: any[], public specificity) { super(); }
constructor(public redirectTo: any[], public specificity: any /** TODO #9100 */) { super(); }
}
// Rules are responsible for recognizing URL segments and generating instructions
@ -44,7 +44,7 @@ export class RedirectRule implements AbstractRule {
* Returns `null` or a `ParsedUrl` representing the new path to match
*/
recognize(beginningSegment: Url): Promise<RouteMatch> {
var match = null;
var match: any /** TODO #9100 */ = null;
if (isPresent(this._pathRecognizer.matchUrl(beginningSegment))) {
match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);
}

View File

@ -3,12 +3,12 @@ import {isPresent, isBlank, RegExpWrapper} from '../src/facade/lang';
import {BaseException} from '../src/facade/exceptions';
export function convertUrlParamsToArray(urlParams: {[key: string]: any}): string[] {
var paramsArray = [];
var paramsArray: any[] /** TODO #9100 */ = [];
if (isBlank(urlParams)) {
return [];
}
StringMapWrapper.forEach(
urlParams, (value, key) => { paramsArray.push((value === true) ? key : key + '=' + value); });
urlParams, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => { paramsArray.push((value === true) ? key : key + '=' + value); });
return paramsArray;
}
@ -126,7 +126,7 @@ export class UrlParser {
// TODO: should these params just be dropped?
this.parseMatrixParams();
}
var child = null;
var child: any /** TODO #9100 */ = null;
if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
this.capture('/');
child = this.parseSegment();

View File

@ -7,7 +7,7 @@ export class TouchMap {
constructor(map: {[key: string]: any}) {
if (isPresent(map)) {
StringMapWrapper.forEach(map, (value, key) => {
StringMapWrapper.forEach(map, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => {
this.map[key] = isPresent(value) ? value.toString() : null;
this.keys[key] = true;
});