Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add types #9606

Merged
merged 1 commit into from Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/@angular/compiler/src/compile_metadata.ts
Expand Up @@ -36,7 +36,7 @@ export abstract class CompileMetadataWithType extends CompileMetadataWithIdentif
}

export function metadataFromJson(data: {[key: string]: any}): any {
return (_COMPILE_METADATA_FROM_JSON as any /** TODO #9100 */)[data['class']](data);
return (_COMPILE_METADATA_FROM_JSON as any)[data['class']](data);
}

export class CompileAnimationEntryMetadata {
Expand Down Expand Up @@ -487,7 +487,7 @@ export class CompileTokenMap<VALUE> {
get(token: CompileTokenMetadata): VALUE {
var rk = token.runtimeCacheKey;
var ak = token.assetCacheKey;
var result: any /** TODO #9100 */;
var result: VALUE;
if (isPresent(rk)) {
result = this._valueMap.get(rk);
}
Expand Down
10 changes: 5 additions & 5 deletions modules/@angular/compiler/src/config.ts
Expand Up @@ -67,9 +67,9 @@ export abstract class RenderTypes {

export class DefaultRenderTypes implements RenderTypes {
renderer = Identifiers.Renderer;
renderText: any /** TODO #9100 */ = null;
renderElement: any /** TODO #9100 */ = null;
renderComment: any /** TODO #9100 */ = null;
renderNode: any /** TODO #9100 */ = null;
renderEvent: any /** TODO #9100 */ = null;
renderText: any = null;
renderElement: any = null;
renderComment: any = null;
renderNode: any = null;
renderEvent: any = null;
}
6 changes: 3 additions & 3 deletions modules/@angular/compiler/src/css_lexer.ts
Expand Up @@ -89,7 +89,7 @@ export class CssScannerError extends BaseException {
public rawMessage: string;
public message: string;

constructor(public token: CssToken, message: any /** TODO #9100 */) {
constructor(public token: CssToken, message: string) {
super('Css Parse Error: ' + message);
this.rawMessage = message;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ export class CssScanner {
next = new CssToken(0, 0, 0, CssTokenType.EOF, 'end of file');
}

var isMatchingType: any /** TODO #9100 */;
var isMatchingType: boolean;
if (type == CssTokenType.IdentifierOrNumber) {
// TODO (matsko): implement array traversal for lookup here
isMatchingType = next.type == CssTokenType.Number || next.type == CssTokenType.Identifier;
Expand All @@ -220,7 +220,7 @@ export class CssScanner {
// mode so that the parser can recover...
this.setMode(mode);

var error: any /** TODO #9100 */ = null;
var error: CssScannerError = null;
if (!isMatchingType || (isPresent(value) && value != next.strValue)) {
var errorMessage = resolveEnumToken(CssTokenType, next.type) + ' does not match expected ' +
resolveEnumToken(CssTokenType, type) + ' value';
Expand Down
14 changes: 7 additions & 7 deletions modules/@angular/compiler/src/css_parser.ts
Expand Up @@ -194,7 +194,7 @@ export class CssParser {
/** @internal */
_parseStyleSheet(delimiters: number): CssStyleSheetAst {
const start = this._getScannerIndex();
var results: any[] /** TODO #9100 */ = [];
var results: CssAst[] = [];
this._scanner.consumeEmptyStatements();
while (this._scanner.peek != chars.$EOF) {
this._scanner.setMode(CssLexerMode.BLOCK);
Expand Down Expand Up @@ -325,7 +325,7 @@ export class CssParser {
_parseSelectors(delimiters: number): CssSelectorAst[] {
delimiters |= LBRACE_DELIM_FLAG | SEMICOLON_DELIM_FLAG;

var selectors: any[] /** TODO #9100 */ = [];
var selectors: CssSelectorAst[] = [];
var isParsingSelectors = true;
while (isParsingSelectors) {
selectors.push(this._parseSelector(delimiters));
Expand Down Expand Up @@ -378,7 +378,7 @@ export class CssParser {

this._consume(CssTokenType.Character, '{');

var definitions: any[] /** TODO #9100 */ = [];
var definitions: CssKeyframeDefinitionAst[] = [];
while (!characterContainsDelimiter(this._scanner.peek, delimiters)) {
definitions.push(this._parseKeyframeDefinition(delimiters));
}
Expand All @@ -392,7 +392,7 @@ export class CssParser {
/** @internal */
_parseKeyframeDefinition(delimiters: number): CssKeyframeDefinitionAst {
const start = this._getScannerIndex();
var stepTokens: any[] /** TODO #9100 */ = [];
var stepTokens: CssToken[] = [];
delimiters |= LBRACE_DELIM_FLAG;
while (!characterContainsDelimiter(this._scanner.peek, delimiters)) {
stepTokens.push(this._parseKeyframeLabel(delimiters | COMMA_DELIM_FLAG));
Expand Down Expand Up @@ -701,7 +701,7 @@ export class CssParser {

/** @internal */
_collectUntilDelim(delimiters: number, assertType: CssTokenType = null): CssToken[] {
var tokens: any[] /** TODO #9100 */ = [];
var tokens: CssToken[] = [];
while (!characterContainsDelimiter(this._scanner.peek, delimiters)) {
var val = isPresent(assertType) ? this._consume(assertType) : this._scan();
tokens.push(val);
Expand All @@ -720,7 +720,7 @@ export class CssParser {
this._consume(CssTokenType.Character, '{');
this._scanner.consumeEmptyStatements();

var results: any[] /** TODO #9100 */ = [];
var results: CssAst[] = [];
while (!characterContainsDelimiter(this._scanner.peek, delimiters)) {
results.push(this._parseRule(delimiters));
}
Expand Down Expand Up @@ -770,7 +770,7 @@ export class CssParser {
this._scanner.setMode(CssLexerMode.STYLE_BLOCK);

var prop = this._consume(CssTokenType.Identifier);
var parseValue: any /** TODO #9100 */, value: any /** TODO #9100 */ = null;
var parseValue: boolean, value: CssStyleValueAst = null;

// the colon value separates the prop from the style.
// there are a few cases as to what could happen if it
Expand Down
Expand Up @@ -34,7 +34,7 @@ const LIFECYCLE_PROPS: Map<any, string> = MapWrapper.createFromPairs([
[LifecycleHooks.AfterViewChecked, 'ngAfterViewChecked'],
]);

export function hasLifecycleHook(hook: LifecycleHooks, token: any /** TODO #9100 */): boolean {
export function hasLifecycleHook(hook: LifecycleHooks, token: any): boolean {
var lcInterface = LIFECYCLE_INTERFACES.get(hook);
var lcProp = LIFECYCLE_PROPS.get(hook);
return reflector.hasLifecycleHook(token, lcInterface, lcProp);
Expand Down
2 changes: 1 addition & 1 deletion modules/@angular/compiler/src/directive_resolver.ts
Expand Up @@ -97,7 +97,7 @@ export class DirectiveResolver {
queries: {[key: string]: any}, directiveType: Type): DirectiveMetadata {
var mergedInputs = isPresent(dm.inputs) ? ListWrapper.concat(dm.inputs, inputs) : inputs;

var mergedOutputs: any /** TODO #9100 */;
var mergedOutputs: string[];
if (isPresent(dm.outputs)) {
dm.outputs.forEach((propName: string) => {
if (ListWrapper.contains(outputs, propName)) {
Expand Down
6 changes: 3 additions & 3 deletions modules/@angular/core/src/application_ref.ts
Expand Up @@ -333,8 +333,8 @@ export class ApplicationRef_ extends ApplicationRef {
zone.run(() => { this._exceptionHandler = _injector.get(ExceptionHandler); });
this._asyncInitDonePromise = this.run(() => {
let inits: Function[] = _injector.get(APP_INITIALIZER, null);
var asyncInitResults: any[] /** TODO #9100 */ = [];
var asyncInitDonePromise: any /** TODO #9100 */;
var asyncInitResults: Promise<any>[] = [];
var asyncInitDonePromise: Promise<any>;
if (isPresent(inits)) {
for (var i = 0; i < inits.length; i++) {
var initResult = inits[i]();
Expand Down Expand Up @@ -378,7 +378,7 @@ export class ApplicationRef_ extends ApplicationRef {

run(callback: Function): any {
var zone = this.injector.get(NgZone);
var result: any /** TODO #9100 */;
var result: any;
// Note: Don't use zone.runGuarded as we want to know about
// the thrown exception!
// Note: the completer needs to be created outside
Expand Down
4 changes: 2 additions & 2 deletions modules/@angular/core/src/di/metadata.ts
Expand Up @@ -51,7 +51,7 @@ import {stringify} from '../facade/lang';
* @stable
*/
export class InjectMetadata {
constructor(public token: any /** TODO #9100 */) {}
constructor(public token: any) {}
toString(): string { return `@Inject(${stringify(this.token)})`; }
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export class OptionalMetadata {
* @stable
*/
export class DependencyMetadata {
get token(): any /** TODO #9100 */ { return null; }
get token(): any { return null; }
}

/**
Expand Down
46 changes: 22 additions & 24 deletions modules/@angular/core/src/di/provider.ts
Expand Up @@ -31,7 +31,7 @@ export class Provider {
/**
* Token used when retrieving this provider. Usually, it is a type {@link Type}.
*/
token: any /** TODO #9100 */;
token: any;

/**
* Binds a DI token to an implementation class.
Expand Down Expand Up @@ -77,7 +77,7 @@ export class Provider {
* expect(injector.get("message")).toEqual('Hello');
* ```
*/
useValue: any /** TODO #9100 */;
useValue: any;

/**
* Binds a DI token to an existing token.
Expand Down Expand Up @@ -111,7 +111,7 @@ export class Provider {
* expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
* ```
*/
useExisting: any /** TODO #9100 */;
useExisting: any;

/**
* Binds a DI token to a function which computes the value.
Expand Down Expand Up @@ -157,15 +157,14 @@ export class Provider {
/** @internal */
_multi: boolean;

constructor(
token: any /** TODO #9100 */, {useClass, useValue, useExisting, useFactory, deps, multi}: {
useClass?: Type,
useValue?: any,
useExisting?: any,
useFactory?: Function,
deps?: Object[],
multi?: boolean
}) {
constructor(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: {
useClass?: Type,
useValue?: any,
useExisting?: any,
useFactory?: Function,
deps?: Object[],
multi?: boolean
}) {
this.token = token;
this.useClass = useClass;
this.useValue = useValue;
Expand Down Expand Up @@ -215,7 +214,7 @@ export class Provider {
* @ts2dart_const
*/
export class Binding extends Provider {
constructor(token: any /** TODO #9100 */, {toClass, toValue, toAlias, toFactory, deps, multi}: {
constructor(token: any, {toClass, toValue, toAlias, toFactory, deps, multi}: {
toClass?: Type,
toValue?: any,
toAlias?: any,
Expand Down Expand Up @@ -264,7 +263,7 @@ export class Binding extends Provider {
*
* @deprecated
*/
export function bind(token: any /** TODO #9100 */): ProviderBuilder {
export function bind(token: any): ProviderBuilder {
return new ProviderBuilder(token);
}

Expand All @@ -273,7 +272,7 @@ export function bind(token: any /** TODO #9100 */): ProviderBuilder {
* @deprecated
*/
export class ProviderBuilder {
constructor(public token: any /** TODO #9100 */) {}
constructor(public token: any) {}

/**
* Binds a DI token to a class.
Expand Down Expand Up @@ -398,15 +397,14 @@ export class ProviderBuilder {
* <!-- TODO: improve the docs -->
* @deprecated
*/
export function provide(
token: any /** TODO #9100 */, {useClass, useValue, useExisting, useFactory, deps, multi}: {
useClass?: Type,
useValue?: any,
useExisting?: any,
useFactory?: Function,
deps?: Object[],
multi?: boolean
}): Provider {
export function provide(token: any, {useClass, useValue, useExisting, useFactory, deps, multi}: {
useClass?: Type,
useValue?: any,
useExisting?: any,
useFactory?: Function,
deps?: Object[],
multi?: boolean
}): Provider {
return new Provider(token, {
useClass: useClass,
useValue: useValue,
Expand Down
28 changes: 14 additions & 14 deletions modules/@angular/core/src/di/reflective_exceptions.ts
Expand Up @@ -8,20 +8,20 @@

import {ListWrapper} from '../facade/collection';
import {BaseException, WrappedException} from '../facade/exceptions';
import {isBlank, stringify} from '../facade/lang';
import {Type, isBlank, stringify} from '../facade/lang';

import {Provider} from './provider';
import {ReflectiveInjector} from './reflective_injector';
import {ReflectiveKey} from './reflective_key';

function findFirstClosedCycle(keys: any[]): any[] {
var res: any[] /** TODO #9100 */ = [];
var res: any[] = [];
for (var i = 0; i < keys.length; ++i) {
if (ListWrapper.contains(res, keys[i])) {
res.push(keys[i]);
return res;
} else {
res.push(keys[i]);
}
res.push(keys[i]);
}
return res;
}
Expand All @@ -31,9 +31,9 @@ function constructResolvingPath(keys: any[]): string {
var reversed = findFirstClosedCycle(ListWrapper.reversed(keys));
var tokenStrs = reversed.map(k => stringify(k.token));
return ' (' + tokenStrs.join(' -> ') + ')';
} else {
return '';
}

return '';
}


Expand Down Expand Up @@ -156,8 +156,8 @@ export class InstantiationError extends WrappedException {
injectors: ReflectiveInjector[];

constructor(
injector: ReflectiveInjector, originalException: any /** TODO #9100 */,
originalStack: any /** TODO #9100 */, key: ReflectiveKey) {
injector: ReflectiveInjector, originalException: any, originalStack: any,
key: ReflectiveKey) {
super('DI Exception', originalException, originalStack, null);
this.keys = [key];
this.injectors = [injector];
Expand Down Expand Up @@ -190,7 +190,7 @@ export class InstantiationError extends WrappedException {
* @stable
*/
export class InvalidProviderError extends BaseException {
constructor(provider: any /** TODO #9100 */) {
constructor(provider: any) {
super(`Invalid provider - only instances of Provider and Type are allowed, got: ${provider}`);
}
}
Expand Down Expand Up @@ -225,12 +225,12 @@ export class InvalidProviderError extends BaseException {
* @stable
*/
export class NoAnnotationError extends BaseException {
constructor(typeOrFunc: any /** TODO #9100 */, params: any[][]) {
constructor(typeOrFunc: Type|Function, params: any[][]) {
super(NoAnnotationError._genMessage(typeOrFunc, params));
}

private static _genMessage(typeOrFunc: any /** TODO #9100 */, params: any[][]) {
var signature: any[] /** TODO #9100 */ = [];
private static _genMessage(typeOrFunc: Type|Function, params: any[][]) {
var signature: string[] = [];
for (var i = 0, ii = params.length; i < ii; i++) {
var parameter = params[i];
if (isBlank(parameter) || parameter.length == 0) {
Expand Down Expand Up @@ -261,7 +261,7 @@ export class NoAnnotationError extends BaseException {
* @stable
*/
export class OutOfBoundsError extends BaseException {
constructor(index: any /** TODO #9100 */) { super(`Index ${index} is out-of-bounds.`); }
constructor(index: number) { super(`Index ${index} is out-of-bounds.`); }
}

// TODO: add a working example after alpha38 is released
Expand All @@ -278,7 +278,7 @@ export class OutOfBoundsError extends BaseException {
* ```
*/
export class MixingMultiProvidersWithRegularProvidersError extends BaseException {
constructor(provider1: any /** TODO #9100 */, provider2: any /** TODO #9100 */) {
constructor(provider1: any, provider2: any) {
super(
'Cannot mix multi providers and regular providers, got: ' + provider1.toString() + ' ' +
provider2.toString());
Expand Down
6 changes: 3 additions & 3 deletions modules/@angular/core/src/di/reflective_injector.ts
Expand Up @@ -737,7 +737,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
throw e;
}

var obj: any /** TODO #9100 */;
var obj: any;
try {
switch (length) {
case 0:
Expand Down Expand Up @@ -890,9 +890,9 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
var INJECTOR_KEY = ReflectiveKey.get(Injector);

function _mapProviders(injector: ReflectiveInjector_, fn: Function): any[] {
var res: any[] /** TODO #9100 */ = [];
var res: any[] = new Array(injector._proto.numberOfProviders);
for (var i = 0; i < injector._proto.numberOfProviders; ++i) {
res.push(fn(injector._proto.getProviderAtIndex(i)));
res[i] = fn(injector._proto.getProviderAtIndex(i));
}
return res;
}