From 1f6fd3c8fc43e4849e5f0eaaf64649b0d4ab2e03 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Sat, 11 Jun 2016 21:23:37 -0700 Subject: [PATCH] refactor: add types (#9148) --- .../common/test/directives/ng_if_spec.ts | 4 +- .../common/test/directives/ng_style_spec.ts | 4 +- .../common/test/forms/directives_spec.ts | 2 +- .../compiler/src/expression_parser/ast.ts | 2 +- .../compiler/src/expression_parser/lexer.ts | 4 +- .../compiler/src/expression_parser/parser.ts | 51 ++++++------------- modules/@angular/compiler/src/html_ast.ts | 2 +- modules/@angular/compiler/src/html_lexer.ts | 23 ++++----- modules/@angular/compiler/src/html_parser.ts | 4 +- .../compiler/src/i18n/i18n_html_parser.ts | 17 +++---- modules/@angular/compiler/src/i18n/shared.ts | 4 +- .../compiler/src/i18n/xmb_serializer.ts | 4 +- .../compiler/src/metadata_resolver.ts | 2 +- .../@angular/compiler/src/offline_compiler.ts | 6 +-- .../@angular/compiler/src/provider_parser.ts | 2 +- .../@angular/compiler/src/runtime_compiler.ts | 6 +-- modules/@angular/compiler/src/selector.ts | 14 ++--- .../@angular/compiler/src/style_compiler.ts | 2 +- .../compiler/src/style_url_resolver.ts | 21 ++++---- modules/@angular/compiler/src/template_ast.ts | 2 +- .../compiler/src/template_preparser.ts | 6 +-- modules/@angular/compiler/src/url_resolver.ts | 2 +- modules/@angular/compiler/src/util.ts | 4 +- modules/@angular/facade/src/lang.ts | 27 +++++----- modules/@angular/facade/src/promise.ts | 2 +- modules/empty.ts | 2 +- 26 files changed, 96 insertions(+), 123 deletions(-) diff --git a/modules/@angular/common/test/directives/ng_if_spec.ts b/modules/@angular/common/test/directives/ng_if_spec.ts index e51c22e03f..f199cd2150 100644 --- a/modules/@angular/common/test/directives/ng_if_spec.ts +++ b/modules/@angular/common/test/directives/ng_if_spec.ts @@ -276,8 +276,6 @@ class TestComponent { this.nestedBooleanCondition = true; this.numberCondition = 1; this.stringCondition = 'foo'; - this.functionCondition = function(s: any /** TODO #9100 */, n: any /** TODO #9100 */) { - return s == 'foo' && n == 1; - }; + this.functionCondition = function(s: any, n: any): boolean { return s == 'foo' && n == 1; }; } } diff --git a/modules/@angular/common/test/directives/ng_style_spec.ts b/modules/@angular/common/test/directives/ng_style_spec.ts index dde8207a87..c148c342ee 100644 --- a/modules/@angular/common/test/directives/ng_style_spec.ts +++ b/modules/@angular/common/test/directives/ng_style_spec.ts @@ -48,7 +48,7 @@ export function main() { .toEqual('40px'); expr = fixture.debugElement.componentInstance.expr; - (expr as any /** TODO #9100 */)['max-width'] = '30%'; + (expr as any)['max-width'] = '30%'; fixture.detectChanges(); expect(getDOM().getStyle( fixture.debugElement.children[0].nativeElement, 'max-width')) @@ -153,5 +153,5 @@ export function main() { @Component({selector: 'test-cmp', directives: [NgStyle], template: ''}) class TestComponent { - expr: any /** TODO #9100 */; + expr: any; } diff --git a/modules/@angular/common/test/forms/directives_spec.ts b/modules/@angular/common/test/forms/directives_spec.ts index 74af843fa2..2f448e1666 100644 --- a/modules/@angular/common/test/forms/directives_spec.ts +++ b/modules/@angular/common/test/forms/directives_spec.ts @@ -13,7 +13,7 @@ import {PromiseWrapper} from '../../src/facade/promise'; import {SimpleChange} from '@angular/core/src/change_detection'; class DummyControlValueAccessor implements ControlValueAccessor { - writtenValue: any /** TODO #9100 */; + writtenValue: any; registerOnChange(fn: any /** TODO #9100 */) {} registerOnTouched(fn: any /** TODO #9100 */) {} diff --git a/modules/@angular/compiler/src/expression_parser/ast.ts b/modules/@angular/compiler/src/expression_parser/ast.ts index d447c2cde0..236cf9a2fd 100644 --- a/modules/@angular/compiler/src/expression_parser/ast.ts +++ b/modules/@angular/compiler/src/expression_parser/ast.ts @@ -94,7 +94,7 @@ export class BindingPipe extends AST { } export class LiteralPrimitive extends AST { - constructor(public value: any /** TODO #9100 */) { super(); } + constructor(public value: any) { super(); } visit(visitor: AstVisitor, context: any = null): any { return visitor.visitLiteralPrimitive(this, context); } diff --git a/modules/@angular/compiler/src/expression_parser/lexer.ts b/modules/@angular/compiler/src/expression_parser/lexer.ts index 2a65c79427..2da9a14778 100644 --- a/modules/@angular/compiler/src/expression_parser/lexer.ts +++ b/modules/@angular/compiler/src/expression_parser/lexer.ts @@ -17,7 +17,7 @@ export enum TokenType { export class Lexer { tokenize(text: string): any[] { var scanner = new _Scanner(text); - var tokens: any[] /** TODO #9100 */ = []; + var tokens: Token[] = []; var token = scanner.scanToken(); while (token != null) { tokens.push(token); @@ -162,7 +162,7 @@ export const $RBRACE = /*@ts2dart_const*/ 125; const $NBSP = /*@ts2dart_const*/ 160; export class ScannerError extends BaseException { - constructor(public message: any /** TODO #9100 */) { super(); } + constructor(public message: string) { super(); } toString(): string { return this.message; } } diff --git a/modules/@angular/compiler/src/expression_parser/parser.ts b/modules/@angular/compiler/src/expression_parser/parser.ts index 3c0a734469..1c7205471f 100644 --- a/modules/@angular/compiler/src/expression_parser/parser.ts +++ b/modules/@angular/compiler/src/expression_parser/parser.ts @@ -85,7 +85,7 @@ export class Parser { let split = this.splitInterpolation(input, location); if (split == null) return null; - let expressions: any[] /** TODO #9100 */ = []; + let expressions: AST[] = []; for (let i = 0; i < split.expressions.length; ++i) { var tokens = this._lexer.tokenize(this._stripComments(split.expressions[i])); @@ -101,8 +101,8 @@ export class Parser { if (parts.length <= 1) { return null; } - var strings: any[] /** TODO #9100 */ = []; - var expressions: any[] /** TODO #9100 */ = []; + var strings: string[] = []; + var expressions: string[] = []; for (var i = 0; i < parts.length; i++) { var part: string = parts[i]; @@ -130,7 +130,7 @@ export class Parser { } private _commentStart(input: string): number { - var outerQuote: any /** TODO #9100 */ = null; + var outerQuote: number = null; for (var i = 0; i < input.length - 1; i++) { let char = StringWrapper.charCodeAt(input, i); let nextChar = StringWrapper.charCodeAt(input, i + 1); @@ -238,7 +238,7 @@ export class _ParseAST { } parseChain(): AST { - var exprs: any[] /** TODO #9100 */ = []; + var exprs: AST[] = []; while (this.index < this.tokens.length) { var expr = this.parsePipe(); exprs.push(expr); @@ -267,7 +267,7 @@ export class _ParseAST { do { var name = this.expectIdentifierOrKeyword(); - var args: any[] /** TODO #9100 */ = []; + var args: AST[] = []; while (this.optionalCharacter($COLON)) { args.push(this.parseExpression()); } @@ -472,8 +472,8 @@ export class _ParseAST { throw new BaseException('Fell through all cases in parsePrimary'); } - parseExpressionList(terminator: number): any[] { - var result: any[] /** TODO #9100 */ = []; + parseExpressionList(terminator: number): AST[] { + var result: AST[] = []; if (!this.next.isCharacter(terminator)) { do { result.push(this.parsePipe()); @@ -483,8 +483,8 @@ export class _ParseAST { } parseLiteralMap(): LiteralMap { - var keys: any[] /** TODO #9100 */ = []; - var values: any[] /** TODO #9100 */ = []; + var keys: string[] = []; + var values: AST[] = []; this.expectCharacter($LBRACE); if (!this.optionalCharacter($RBRACE)) { do { @@ -532,34 +532,13 @@ export class _ParseAST { parseCallArguments(): BindingPipe[] { if (this.next.isCharacter($RPAREN)) return []; - var positionals: any[] /** TODO #9100 */ = []; + var positionals: AST[] = []; do { positionals.push(this.parsePipe()); } while (this.optionalCharacter($COMMA)); - return positionals; + return positionals as BindingPipe[]; } - parseBlockContent(): AST { - if (!this.parseAction) { - this.error('Binding expression cannot contain chained expression'); - } - var exprs: any[] /** TODO #9100 */ = []; - while (this.index < this.tokens.length && !this.next.isCharacter($RBRACE)) { - var expr = this.parseExpression(); - exprs.push(expr); - - if (this.optionalCharacter($SEMICOLON)) { - while (this.optionalCharacter($SEMICOLON)) { - } // read all semicolons - } - } - if (exprs.length == 0) return new EmptyExpr(); - if (exprs.length == 1) return exprs[0]; - - return new Chain(exprs); - } - - /** * An identifier, a keyword, a string with an optional `-` inbetween. */ @@ -579,7 +558,7 @@ export class _ParseAST { parseTemplateBindings(): TemplateBindingParseResult { var bindings: TemplateBinding[] = []; - var prefix: any /** TODO #9100 */ = null; + var prefix: string = null; var warnings: string[] = []; while (this.index < this.tokens.length) { var keyIsVar: boolean = this.peekKeywordLet(); @@ -603,8 +582,8 @@ export class _ParseAST { } } this.optionalCharacter($COLON); - var name: any /** TODO #9100 */ = null; - var expression: any /** TODO #9100 */ = null; + var name: string = null; + var expression: ASTWithSource = null; if (keyIsVar) { if (this.optionalOperator('=')) { name = this.expectTemplateBindingKey(); diff --git a/modules/@angular/compiler/src/html_ast.ts b/modules/@angular/compiler/src/html_ast.ts index 5ada491611..e9bc8f2c95 100644 --- a/modules/@angular/compiler/src/html_ast.ts +++ b/modules/@angular/compiler/src/html_ast.ts @@ -59,7 +59,7 @@ export interface HtmlAstVisitor { } export function htmlVisitAll(visitor: HtmlAstVisitor, asts: HtmlAst[], context: any = null): any[] { - var result: any[] /** TODO #9100 */ = []; + var result: any[] = []; asts.forEach(ast => { var astResult = ast.visit(visitor, context); if (isPresent(astResult)) { diff --git a/modules/@angular/compiler/src/html_lexer.ts b/modules/@angular/compiler/src/html_lexer.ts index 7ceca3712c..c4b9023d34 100644 --- a/modules/@angular/compiler/src/html_lexer.ts +++ b/modules/@angular/compiler/src/html_lexer.ts @@ -362,7 +362,7 @@ class _HtmlTokenizer { } this._advance(); let name = this._input.substring(start.offset + 1, this._index - 1); - let char = (NAMED_ENTITIES as any /** TODO #9100 */)[name]; + let char = (NAMED_ENTITIES as any)[name]; if (isBlank(char)) { throw this._createError(unknownEntityErrorMsg(name), this._getSpan(start)); } @@ -372,11 +372,11 @@ class _HtmlTokenizer { private _consumeRawText( decodeEntities: boolean, firstCharOfEnd: number, attemptEndRest: Function): HtmlToken { - var tagCloseStart: any /** TODO #9100 */; + var tagCloseStart: ParseLocation; var textStart = this._getLocation(); this._beginToken( decodeEntities ? HtmlTokenType.ESCAPABLE_RAW_TEXT : HtmlTokenType.RAW_TEXT, textStart); - var parts: any[] /** TODO #9100 */ = []; + var parts: string[] = []; while (true) { tagCloseStart = this._getLocation(); if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) { @@ -419,11 +419,11 @@ class _HtmlTokenizer { private _consumePrefixAndName(): string[] { var nameOrPrefixStart = this._index; - var prefix: any /** TODO #9100 */ = null; + var prefix: string = null; while (this._peek !== $COLON && !isPrefixEnd(this._peek)) { this._advance(); } - var nameStart: any /** TODO #9100 */; + var nameStart: number; if (this._peek === $COLON) { this._advance(); prefix = this._input.substring(nameOrPrefixStart, this._index - 1); @@ -438,7 +438,7 @@ class _HtmlTokenizer { private _consumeTagOpen(start: ParseLocation) { let savedPos = this._savePosition(); - let lowercaseTagName: any /** TODO #9100 */; + let lowercaseTagName: string; try { if (!isAsciiLetter(this._peek)) { throw this._createError(unexpectedCharacterErrorMsg(this._peek), this._getSpan()); @@ -505,11 +505,11 @@ class _HtmlTokenizer { private _consumeAttributeValue() { this._beginToken(HtmlTokenType.ATTR_VALUE); - var value: any /** TODO #9100 */; + var value: string; if (this._peek === $SQ || this._peek === $DQ) { var quoteChar = this._peek; this._advance(); - var parts: any[] /** TODO #9100 */ = []; + var parts: string[] = []; while (this._peek !== quoteChar) { parts.push(this._readChar(true)); } @@ -534,8 +534,7 @@ class _HtmlTokenizer { private _consumeTagClose(start: ParseLocation) { this._beginToken(HtmlTokenType.TAG_CLOSE, start); this._attemptCharCodeUntilFn(isNotWhitespace); - var prefixAndName: any /** TODO #9100 */; - prefixAndName = this._consumePrefixAndName(); + let prefixAndName = this._consumePrefixAndName(); this._attemptCharCodeUntilFn(isNotWhitespace); this._requireCharCode($GT); this._endToken(prefixAndName); @@ -596,7 +595,7 @@ class _HtmlTokenizer { var start = this._getLocation(); this._beginToken(HtmlTokenType.TEXT, start); - var parts: any[] /** TODO #9100 */ = []; + var parts: string[] = []; let interpolation = false; if (this._peek === $LBRACE && this._nextPeek === $LBRACE) { @@ -719,7 +718,7 @@ function toUpperCaseCharCode(code: number): number { } function mergeTextTokens(srcTokens: HtmlToken[]): HtmlToken[] { - let dstTokens: any[] /** TODO #9100 */ = []; + let dstTokens: HtmlToken[] = []; let lastDstToken: HtmlToken; for (let i = 0; i < srcTokens.length; i++) { let token = srcTokens[i]; diff --git a/modules/@angular/compiler/src/html_parser.ts b/modules/@angular/compiler/src/html_parser.ts index b9398f240a..04c795a75e 100644 --- a/modules/@angular/compiler/src/html_parser.ts +++ b/modules/@angular/compiler/src/html_parser.ts @@ -160,7 +160,7 @@ class TreeBuilder { } private _collectExpansionExpTokens(start: HtmlToken): HtmlToken[] { - let exp: any[] /** TODO #9100 */ = []; + let exp: HtmlToken[] = []; let expansionFormStack = [HtmlTokenType.EXPANSION_CASE_EXP_START]; while (true) { @@ -229,7 +229,7 @@ class TreeBuilder { private _consumeStartTag(startTagToken: HtmlToken) { var prefix = startTagToken.parts[0]; var name = startTagToken.parts[1]; - var attrs: any[] /** TODO #9100 */ = []; + var attrs: HtmlAttrAst[] = []; while (this.peek.type === HtmlTokenType.ATTR_NAME) { attrs.push(this._consumeAttr(this._advance())); } diff --git a/modules/@angular/compiler/src/i18n/i18n_html_parser.ts b/modules/@angular/compiler/src/i18n/i18n_html_parser.ts index 7091c42079..4c9fdc7ffd 100644 --- a/modules/@angular/compiler/src/i18n/i18n_html_parser.ts +++ b/modules/@angular/compiler/src/i18n/i18n_html_parser.ts @@ -7,7 +7,7 @@ import {HtmlParseTreeResult, HtmlParser} from '../html_parser'; import {ParseError, ParseSourceSpan} from '../parse_util'; import {expandNodes} from './expander'; -import {id} from './message'; +import {Message, id} from './message'; import {I18N_ATTR, I18N_ATTR_PREFIX, I18nError, Part, dedupePhName, getPhNameFromBinding, messageFromAttribute, messageFromI18nAttribute, partition} from './shared'; const _PLACEHOLDER_ELEMENT = 'ph'; @@ -260,14 +260,14 @@ export class I18nHtmlParser implements HtmlParser { } private _i18nAttributes(el: HtmlElementAst): HtmlAttrAst[] { - let res: any[] /** TODO #9100 */ = []; + let res: HtmlAttrAst[] = []; let implicitAttrs: string[] = isPresent(this._implicitAttrs[el.name]) ? this._implicitAttrs[el.name] : []; el.attrs.forEach(attr => { if (attr.name.startsWith(I18N_ATTR_PREFIX) || attr.name == I18N_ATTR) return; - let message: any /** TODO #9100 */; + let message: Message; let i18ns = el.attrs.filter(a => a.name == `${I18N_ATTR_PREFIX}${attr.name}`); @@ -314,12 +314,11 @@ export class I18nHtmlParser implements HtmlParser { private _replacePlaceholdersWithExpressions( message: string, exps: string[], sourceSpan: ParseSourceSpan): string { let expMap = this._buildExprMap(exps); - return RegExpWrapper.replaceAll( - _PLACEHOLDER_EXPANDED_REGEXP, message, (match: any /** TODO #9100 */) => { - let nameWithQuotes = match[2]; - let name = nameWithQuotes.substring(1, nameWithQuotes.length - 1); - return this._convertIntoExpression(name, expMap, sourceSpan); - }); + return RegExpWrapper.replaceAll(_PLACEHOLDER_EXPANDED_REGEXP, message, (match: string[]) => { + let nameWithQuotes = match[2]; + let name = nameWithQuotes.substring(1, nameWithQuotes.length - 1); + return this._convertIntoExpression(name, expMap, sourceSpan); + }); } private _buildExprMap(exps: string[]): Map { diff --git a/modules/@angular/compiler/src/i18n/shared.ts b/modules/@angular/compiler/src/i18n/shared.ts index 0e47c82602..f80098614d 100644 --- a/modules/@angular/compiler/src/i18n/shared.ts +++ b/modules/@angular/compiler/src/i18n/shared.ts @@ -19,11 +19,11 @@ export class I18nError extends ParseError { // Man, this is so ugly! export function partition(nodes: HtmlAst[], errors: ParseError[], implicitTags: string[]): Part[] { - let res: any[] /** TODO #9100 */ = []; + let res: Part[] = []; for (let i = 0; i < nodes.length; ++i) { let n = nodes[i]; - let temp: any[] /** TODO #9100 */ = []; + let temp: HtmlAst[] = []; if (_isOpeningComment(n)) { let i18n = (n).value.substring(5).trim(); i++; diff --git a/modules/@angular/compiler/src/i18n/xmb_serializer.ts b/modules/@angular/compiler/src/i18n/xmb_serializer.ts index af098e8a95..ba83ea7b9d 100644 --- a/modules/@angular/compiler/src/i18n/xmb_serializer.ts +++ b/modules/@angular/compiler/src/i18n/xmb_serializer.ts @@ -40,7 +40,7 @@ export function deserializeXmb(content: string, url: string): XmbDeserialization } let bundleEl = parsed.rootNodes[0]; // test this - let errors: any[] /** TODO #9100 */ = []; + let errors: ParseError[] = []; let messages: {[key: string]: HtmlAst[]} = {}; _createMessages(bundleEl.children, messages, errors); @@ -90,7 +90,7 @@ function _serializeMessage(m: Message): string { } function _expandPlaceholder(input: string): string { - return RegExpWrapper.replaceAll(_PLACEHOLDER_REGEXP, input, (match: any /** TODO #9100 */) => { + return RegExpWrapper.replaceAll(_PLACEHOLDER_REGEXP, input, (match: string[]) => { let nameWithQuotes = match[2]; return ``; }); diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 9fb49ab2ea..28f2000e45 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -96,7 +96,7 @@ export class CompileMetadataResolver { var meta = this._directiveCache.get(directiveType); if (isBlank(meta)) { var dirMeta = this._directiveResolver.resolve(directiveType); - var templateMeta: any /** TODO #9100 */ = null; + var templateMeta: cpl.CompileTemplateMetadata = null; var changeDetectionStrategy: any /** TODO #9100 */ = null; var viewProviders: any[] /** TODO #9100 */ = []; var moduleUrl = staticTypeModuleUrl(directiveType); diff --git a/modules/@angular/compiler/src/offline_compiler.ts b/modules/@angular/compiler/src/offline_compiler.ts index 79c43f0c89..7babcff5b7 100644 --- a/modules/@angular/compiler/src/offline_compiler.ts +++ b/modules/@angular/compiler/src/offline_compiler.ts @@ -47,8 +47,8 @@ export class OfflineCompiler { if (components.length === 0) { throw new BaseException('No components given'); } - var statements: any[] /** TODO #9100 */ = []; - var exportedVars: any[] /** TODO #9100 */ = []; + var statements: o.DeclareVarStmt[] = []; + var exportedVars: string[] = []; var moduleUrl = _templateModuleUrl(components[0].component); components.forEach(componentWithDirs => { var compMeta = componentWithDirs.component; @@ -81,7 +81,7 @@ export class OfflineCompiler { Promise { return this._xhr.get(stylesheetUrl).then((cssText) => { var compileResult = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, shim); - var importedUrls: any[] /** TODO #9100 */ = []; + var importedUrls: string[] = []; compileResult.dependencies.forEach((dep) => { importedUrls.push(dep.moduleUrl); dep.valuePlaceholder.moduleUrl = _stylesModuleUrl(dep.moduleUrl, dep.isShimmed, suffix); diff --git a/modules/@angular/compiler/src/provider_parser.ts b/modules/@angular/compiler/src/provider_parser.ts index fa27ead27b..eb17483005 100644 --- a/modules/@angular/compiler/src/provider_parser.ts +++ b/modules/@angular/compiler/src/provider_parser.ts @@ -149,7 +149,7 @@ export class ProviderElementContext { var transformedProviders = resolvedProvider.providers.map((provider) => { var transformedUseValue = provider.useValue; var transformedUseExisting = provider.useExisting; - var transformedDeps: any /** TODO #9100 */; + var transformedDeps: CompileDiDependencyMetadata[]; if (isPresent(provider.useExisting)) { var existingDiDep = this._getDependency( resolvedProvider.providerType, diff --git a/modules/@angular/compiler/src/runtime_compiler.ts b/modules/@angular/compiler/src/runtime_compiler.ts index 1c810fdcc7..504eab0074 100644 --- a/modules/@angular/compiler/src/runtime_compiler.ts +++ b/modules/@angular/compiler/src/runtime_compiler.ts @@ -89,7 +89,7 @@ export class RuntimeCompiler implements ComponentResolver { compMeta, compMeta.template.template, normalizedViewDirMetas, pipes, compMeta.type.name); - var childPromises: any[] /** TODO #9100 */ = []; + var childPromises: Promise[] = []; compiledTemplate.init(this._compileComponent( compMeta, parsedTemplate, styles, pipes, compilingComponentsPath, childPromises)); @@ -128,7 +128,7 @@ export class RuntimeCompiler implements ComponentResolver { childPromises.push(this._compiledTemplateDone.get(childCacheKey)); } }); - var factory: any /** TODO #9100 */; + var factory: any; if (IS_DART || !this._genConfig.useJit) { factory = interpretStatements( compileResult.statements, compileResult.viewFactoryVar, @@ -151,7 +151,7 @@ export class RuntimeCompiler implements ComponentResolver { var promises = result.dependencies.map((dep) => this._loadStylesheetDep(dep)); return PromiseWrapper.all(promises) .then((cssTexts) => { - var nestedCompileResultPromises: any[] /** TODO #9100 */ = []; + var nestedCompileResultPromises: Promise[] = []; for (var i = 0; i < result.dependencies.length; i++) { var dep = result.dependencies[i]; var cssText = cssTexts[i]; diff --git a/modules/@angular/compiler/src/selector.ts b/modules/@angular/compiler/src/selector.ts index 9e48a9b968..2f6a41a43e 100644 --- a/modules/@angular/compiler/src/selector.ts +++ b/modules/@angular/compiler/src/selector.ts @@ -27,7 +27,7 @@ export class CssSelector { static parse(selector: string): CssSelector[] { var results: CssSelector[] = []; - var _addResult = (res: CssSelector[], cssSel: any /** TODO #9100 */) => { + var _addResult = (res: CssSelector[], cssSel: CssSelector) => { if (cssSel.notSelectors.length > 0 && isBlank(cssSel.element) && ListWrapper.isEmpty(cssSel.classNames) && ListWrapper.isEmpty(cssSel.attrs)) { cssSel.element = '*'; @@ -36,7 +36,7 @@ export class CssSelector { }; var cssSelector = new CssSelector(); var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector); - var match: any /** TODO #9100 */; + var match: string[]; var current = cssSelector; var inNot = false; while (isPresent(match = RegExpMatcherWrapper.next(matcher))) { @@ -153,7 +153,7 @@ export class SelectorMatcher { private _listContexts: SelectorListContext[] = []; addSelectables(cssSelectors: CssSelector[], callbackCtxt?: any) { - var listContext: any /** TODO #9100 */ = null; + var listContext: SelectorListContext = null; if (cssSelectors.length > 1) { listContext = new SelectorListContext(cssSelectors); this._listContexts.push(listContext); @@ -303,7 +303,7 @@ export class SelectorMatcher { /** @internal */ _matchTerminal( - map: Map, name: any /** TODO #9100 */, cssSelector: CssSelector, + map: Map, name: string, cssSelector: CssSelector, matchedCallback: (c: CssSelector, a: any) => void): boolean { if (isBlank(map) || isBlank(name)) { return false; @@ -317,7 +317,7 @@ export class SelectorMatcher { if (isBlank(selectables)) { return false; } - var selectable: any /** TODO #9100 */; + var selectable: SelectorContext; var result = false; for (var index = 0; index < selectables.length; index++) { selectable = selectables[index]; @@ -328,8 +328,8 @@ export class SelectorMatcher { /** @internal */ _matchPartial( - map: Map, name: any /** TODO #9100 */, cssSelector: CssSelector, - matchedCallback: any /** TODO #9100 */ /*: (c: CssSelector, a: any) => void*/): boolean { + map: Map, name: string, cssSelector: CssSelector, + matchedCallback: (c: CssSelector, a: any) => void): boolean { if (isBlank(map) || isBlank(name)) { return false; } diff --git a/modules/@angular/compiler/src/style_compiler.ts b/modules/@angular/compiler/src/style_compiler.ts index 5e6574c639..c4e8a0f938 100644 --- a/modules/@angular/compiler/src/style_compiler.ts +++ b/modules/@angular/compiler/src/style_compiler.ts @@ -48,7 +48,7 @@ export class StyleCompiler { shim: boolean): StylesCompileResult { var styleExpressions = plainStyles.map(plainStyle => o.literal(this._shimIfNeeded(plainStyle, shim))); - var dependencies: any[] /** TODO #9100 */ = []; + var dependencies: StylesCompileDependency[] = []; for (var i = 0; i < absUrls.length; i++) { var identifier = new CompileIdentifierMetadata({name: getStylesVarName(null)}); dependencies.push(new StylesCompileDependency(absUrls[i], shim, identifier)); diff --git a/modules/@angular/compiler/src/style_url_resolver.ts b/modules/@angular/compiler/src/style_url_resolver.ts index 08392aad21..b385655622 100644 --- a/modules/@angular/compiler/src/style_url_resolver.ts +++ b/modules/@angular/compiler/src/style_url_resolver.ts @@ -21,17 +21,16 @@ export function isStyleUrlResolvable(url: string): boolean { */ export function extractStyleUrls( resolver: UrlResolver, baseUrl: string, cssText: string): StyleWithImports { - var foundUrls: any[] /** TODO #9100 */ = []; - var modifiedCssText = - StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m: any /** TODO #9100 */) => { - var url = isPresent(m[1]) ? m[1] : m[2]; - if (!isStyleUrlResolvable(url)) { - // Do not attempt to resolve non-package absolute URLs with URI scheme - return m[0]; - } - foundUrls.push(resolver.resolve(baseUrl, url)); - return ''; - }); + var foundUrls: string[] = []; + var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m: string[]) => { + var url = isPresent(m[1]) ? m[1] : m[2]; + if (!isStyleUrlResolvable(url)) { + // Do not attempt to resolve non-package absolute URLs with URI scheme + return m[0]; + } + foundUrls.push(resolver.resolve(baseUrl, url)); + return ''; + }); return new StyleWithImports(modifiedCssText, foundUrls); } diff --git a/modules/@angular/compiler/src/template_ast.ts b/modules/@angular/compiler/src/template_ast.ts index 4b8e94c7b8..8db08c600a 100644 --- a/modules/@angular/compiler/src/template_ast.ts +++ b/modules/@angular/compiler/src/template_ast.ts @@ -248,7 +248,7 @@ export interface TemplateAstVisitor { */ export function templateVisitAll( visitor: TemplateAstVisitor, asts: TemplateAst[], context: any = null): any[] { - var result: any[] /** TODO #9100 */ = []; + var result: any[] = []; asts.forEach(ast => { var astResult = ast.visit(visitor, context); if (isPresent(astResult)) { diff --git a/modules/@angular/compiler/src/template_preparser.ts b/modules/@angular/compiler/src/template_preparser.ts index ddaf8260b7..7baa21cede 100644 --- a/modules/@angular/compiler/src/template_preparser.ts +++ b/modules/@angular/compiler/src/template_preparser.ts @@ -15,9 +15,9 @@ const NG_NON_BINDABLE_ATTR = 'ngNonBindable'; const NG_PROJECT_AS = 'ngProjectAs'; export function preparseElement(ast: HtmlElementAst): PreparsedElement { - var selectAttr: any /** TODO #9100 */ = null; - var hrefAttr: any /** TODO #9100 */ = null; - var relAttr: any /** TODO #9100 */ = null; + var selectAttr: string = null; + var hrefAttr: string = null; + var relAttr: string = null; var nonBindable = false; var projectAs: string = null; ast.attrs.forEach(attr => { diff --git a/modules/@angular/compiler/src/url_resolver.ts b/modules/@angular/compiler/src/url_resolver.ts index 6020545572..39397d5200 100644 --- a/modules/@angular/compiler/src/url_resolver.ts +++ b/modules/@angular/compiler/src/url_resolver.ts @@ -101,7 +101,7 @@ export function getUrlScheme(url: string): string { function _buildFromEncodedParts( opt_scheme?: string, opt_userInfo?: string, opt_domain?: string, opt_port?: string, opt_path?: string, opt_queryData?: string, opt_fragment?: string): string { - var out: any[] /** TODO #9100 */ = []; + var out: string[] = []; if (isPresent(opt_scheme)) { out.push(opt_scheme + ':'); diff --git a/modules/@angular/compiler/src/util.ts b/modules/@angular/compiler/src/util.ts index 3b520028e9..56bee5731a 100644 --- a/modules/@angular/compiler/src/util.ts +++ b/modules/@angular/compiler/src/util.ts @@ -8,12 +8,12 @@ var DASH_CASE_REGEXP = /-([a-z])/g; export function camelCaseToDashCase(input: string): string { return StringWrapper.replaceAllMapped( - input, CAMEL_CASE_REGEXP, (m: any /** TODO #9100 */) => { return '-' + m[1].toLowerCase(); }); + input, CAMEL_CASE_REGEXP, (m: string[]) => { return '-' + m[1].toLowerCase(); }); } export function dashCaseToCamelCase(input: string): string { return StringWrapper.replaceAllMapped( - input, DASH_CASE_REGEXP, (m: any /** TODO #9100 */) => { return m[1].toUpperCase(); }); + input, DASH_CASE_REGEXP, (m: string[]) => { return m[1].toUpperCase(); }); } export function splitAtColon(input: string, defaultValues: string[]): string[] { diff --git a/modules/@angular/facade/src/lang.ts b/modules/@angular/facade/src/lang.ts index b6c752165b..b93803ef3f 100644 --- a/modules/@angular/facade/src/lang.ts +++ b/modules/@angular/facade/src/lang.ts @@ -157,13 +157,13 @@ export function isArray(obj: any): boolean { return Array.isArray(obj); } -export function isDate(obj: any /** TODO #9100 */): boolean { +export function isDate(obj: any): obj is Date { return obj instanceof Date && !isNaN(obj.valueOf()); } export function noop() {} -export function stringify(token: any /** TODO #9100 */): string { +export function stringify(token: any): string { if (typeof token === 'string') { return token; } @@ -187,16 +187,15 @@ export function stringify(token: any /** TODO #9100 */): string { // serialize / deserialize enum exist only for consistency with dart API // enums in typescript don't need to be serialized -export function serializeEnum(val: any /** TODO #9100 */): number { +export function serializeEnum(val: any): number { return val; } -export function deserializeEnum(val: any /** TODO #9100 */, values: Map): any { +export function deserializeEnum(val: any, values: Map): any { return val; } -export function resolveEnumToken( - enumValue: any /** TODO #9100 */, val: any /** TODO #9100 */): string { +export function resolveEnumToken(enumValue: any, val: any): string { return enumValue[val]; } @@ -246,7 +245,7 @@ export class StringWrapper { } static replaceAllMapped(s: string, from: RegExp, cb: Function): string { - return s.replace(from, function(...matches: any[] /** TODO #9100 */) { + return s.replace(from, function(...matches: any[]) { // Remove offset & string from the result array matches.splice(-2, 2); // The callback receives match, p1, ..., pn @@ -268,7 +267,7 @@ export class StringWrapper { } export class StringJoiner { - constructor(public parts: any[] /** TODO #9100 */ = []) {} + constructor(public parts: string[] = []) {} add(part: string): void { this.parts.push(part); } @@ -379,7 +378,7 @@ export class FunctionWrapper { } // JS has NaN !== NaN -export function looseIdentical(a: any /** TODO #9100 */, b: any /** TODO #9100 */): boolean { +export function looseIdentical(a: any, b: any): boolean { return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b); } @@ -449,8 +448,8 @@ export function setValueOnPath(global: any, path: string, value: any) { } // When Symbol.iterator doesn't exist, retrieves the key used in es6-shim -declare var Symbol: any /** TODO #9100 */; -var _symbolIterator: any /** TODO #9100 */ = null; +declare var Symbol: any; +var _symbolIterator: any = null; export function getSymbolIterator(): string|symbol { if (isBlank(_symbolIterator)) { if (isPresent((globalScope).Symbol) && isPresent(Symbol.iterator)) { @@ -461,7 +460,7 @@ export function getSymbolIterator(): string|symbol { for (var i = 0; i < keys.length; ++i) { var key = keys[i]; if (key !== 'entries' && key !== 'size' && - (Map as any /** TODO #9100 */).prototype[key] === Map.prototype['entries']) { + (Map as any).prototype[key] === Map.prototype['entries']) { _symbolIterator = key; } } @@ -473,8 +472,8 @@ export function getSymbolIterator(): string|symbol { export function evalExpression( sourceUrl: string, expr: string, declarations: string, vars: {[key: string]: any}): any { var fnBody = `${declarations}\nreturn ${expr}\n//# sourceURL=${sourceUrl}`; - var fnArgNames: any[] /** TODO #9100 */ = []; - var fnArgValues: any[] /** TODO #9100 */ = []; + var fnArgNames: string[] = []; + var fnArgValues: any[] = []; for (var argName in vars) { fnArgNames.push(argName); fnArgValues.push(vars[argName]); diff --git a/modules/@angular/facade/src/promise.ts b/modules/@angular/facade/src/promise.ts index 83c162d0da..5747a209a9 100644 --- a/modules/@angular/facade/src/promise.ts +++ b/modules/@angular/facade/src/promise.ts @@ -15,7 +15,7 @@ export class PromiseCompleter { export class PromiseWrapper { static resolve(obj: T): Promise { return Promise.resolve(obj); } - static reject(obj: any, _: any /** TODO #9100 */): Promise { return Promise.reject(obj); } + static reject(obj: any, _: any): Promise { return Promise.reject(obj); } // Note: We can't rename this method into `catch`, as this is not a valid // method name in Dart. diff --git a/modules/empty.ts b/modules/empty.ts index 3ed7df017e..7e627f6ca7 100644 --- a/modules/empty.ts +++ b/modules/empty.ts @@ -1,4 +1,4 @@ // This file intentionally left blank. It is used to load nothing in some cases. // Such as parse5/index is redirected here instead of loading into browser. -export var __empty__: any /** TODO #9100 */; +export var __empty__: any;