refactor(compiler): improve types, misc

This commit is contained in:
Victor Berchet 2016-10-07 17:36:08 -07:00 committed by Tobias Bosch
parent 79e1c7b807
commit bdcf46f82e
26 changed files with 115 additions and 119 deletions

View File

@ -61,7 +61,9 @@ class _AnimationBuilder implements AnimationAstVisitor {
} }
ast.styles.forEach(entry => { ast.styles.forEach(entry => {
stylesArr.push(o.literalMap(Object.keys(entry).map(key => [key, o.literal(entry[key])]))); const entries =
Object.keys(entry).map((key): [string, o.Expression] => [key, o.literal(entry[key])]);
stylesArr.push(o.literalMap(entries));
}); });
return o.importExpr(resolveIdentifier(Identifiers.AnimationStyles)).instantiate([ return o.importExpr(resolveIdentifier(Identifiers.AnimationStyles)).instantiate([

View File

@ -115,13 +115,10 @@ function _parseAnimationStateTransition(
stateStyles: {[key: string]: AnimationStylesAst}, stateStyles: {[key: string]: AnimationStylesAst},
errors: AnimationParseError[]): AnimationStateTransitionAst { errors: AnimationParseError[]): AnimationStateTransitionAst {
var styles = new StylesCollection(); var styles = new StylesCollection();
var transitionExprs: any[] /** TODO #9100 */ = []; var transitionExprs: AnimationStateTransitionExpression[] = [];
var transitionStates = transitionStateMetadata.stateChangeExpr.split(/\s*,\s*/); var transitionStates = transitionStateMetadata.stateChangeExpr.split(/\s*,\s*/);
transitionStates.forEach(expr => { transitionStates.forEach(
_parseAnimationTransitionExpr(expr, errors).forEach(transExpr => { expr => { transitionExprs.push(..._parseAnimationTransitionExpr(expr, errors)); });
transitionExprs.push(transExpr);
});
});
var entry = _normalizeAnimationEntry(transitionStateMetadata.steps); var entry = _normalizeAnimationEntry(transitionStateMetadata.steps);
var animation = _normalizeStyleSteps(entry, stateStyles, errors); var animation = _normalizeStyleSteps(entry, stateStyles, errors);
var animationAst = _parseTransitionAnimation(animation, 0, styles, stateStyles, errors); var animationAst = _parseTransitionAnimation(animation, 0, styles, stateStyles, errors);
@ -181,8 +178,8 @@ function _normalizeAnimationEntry(entry: CompileAnimationMetadata | CompileAnima
function _normalizeStyleMetadata( function _normalizeStyleMetadata(
entry: CompileAnimationStyleMetadata, stateStyles: {[key: string]: AnimationStylesAst}, entry: CompileAnimationStyleMetadata, stateStyles: {[key: string]: AnimationStylesAst},
errors: AnimationParseError[]): Array<{[key: string]: string | number}> { errors: AnimationParseError[]): {[key: string]: string | number}[] {
var normalizedStyles: any[] /** TODO #9100 */ = []; var normalizedStyles: {[key: string]: string | number}[] = [];
entry.styles.forEach(styleEntry => { entry.styles.forEach(styleEntry => {
if (isString(styleEntry)) { if (isString(styleEntry)) {
ListWrapper.addAll( ListWrapper.addAll(
@ -354,7 +351,6 @@ function _parseAnimationKeyframes(
ListWrapper.sort(rawKeyframes, (a, b) => a[0] <= b[0] ? -1 : 1); ListWrapper.sort(rawKeyframes, (a, b) => a[0] <= b[0] ? -1 : 1);
} }
var i: any /** TODO #9100 */;
var firstKeyframe = rawKeyframes[0]; var firstKeyframe = rawKeyframes[0];
if (firstKeyframe[0] != _INITIAL_KEYFRAME) { if (firstKeyframe[0] != _INITIAL_KEYFRAME) {
ListWrapper.insert(rawKeyframes, 0, firstKeyframe = [_INITIAL_KEYFRAME, {}]); ListWrapper.insert(rawKeyframes, 0, firstKeyframe = [_INITIAL_KEYFRAME, {}]);
@ -369,7 +365,7 @@ function _parseAnimationKeyframes(
} }
var lastKeyframeStyles = lastKeyframe[1]; var lastKeyframeStyles = lastKeyframe[1];
for (i = 1; i <= limit; i++) { for (let i = 1; i <= limit; i++) {
let entry = rawKeyframes[i]; let entry = rawKeyframes[i];
let styles = entry[1]; let styles = entry[1];
@ -380,7 +376,7 @@ function _parseAnimationKeyframes(
}); });
} }
for (i = limit - 1; i >= 0; i--) { for (let i = limit - 1; i >= 0; i--) {
let entry = rawKeyframes[i]; let entry = rawKeyframes[i];
let styles = entry[1]; let styles = entry[1];

View File

@ -368,7 +368,7 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex
var useNewLine = ast.entries.length > 1; var useNewLine = ast.entries.length > 1;
ctx.print(`{`, useNewLine); ctx.print(`{`, useNewLine);
ctx.incIndent(); ctx.incIndent();
this.visitAllObjects((entry: any /** TODO #9100 */) => { this.visitAllObjects(entry => {
ctx.print(`${escapeIdentifier(entry[0], this._escapeDollarInStrings, false)}: `); ctx.print(`${escapeIdentifier(entry[0], this._escapeDollarInStrings, false)}: `);
entry[1].visitExpression(this, ctx); entry[1].visitExpression(this, ctx);
}, ast.entries, ctx, ',', useNewLine); }, ast.entries, ctx, ',', useNewLine);
@ -381,12 +381,11 @@ export abstract class AbstractEmitterVisitor implements o.StatementVisitor, o.Ex
expressions: o.Expression[], ctx: EmitterVisitorContext, separator: string, expressions: o.Expression[], ctx: EmitterVisitorContext, separator: string,
newLine: boolean = false): void { newLine: boolean = false): void {
this.visitAllObjects( this.visitAllObjects(
(expr: any /** TODO #9100 */) => expr.visitExpression(this, ctx), expressions, ctx, expr => expr.visitExpression(this, ctx), expressions, ctx, separator, newLine);
separator, newLine);
} }
visitAllObjects( visitAllObjects<T>(
handler: Function, expressions: any, ctx: EmitterVisitorContext, separator: string, handler: (t: T) => void, expressions: T[], ctx: EmitterVisitorContext, separator: string,
newLine: boolean = false): void { newLine: boolean = false): void {
for (var i = 0; i < expressions.length; i++) { for (var i = 0; i < expressions.length; i++) {
if (i > 0) { if (i > 0) {

View File

@ -144,11 +144,11 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
} }
private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void { private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void {
this.visitAllObjects((param: any /** TODO #9100 */) => ctx.print(param.name), params, ctx, ','); this.visitAllObjects(param => ctx.print(param.name), params, ctx, ',');
} }
getBuiltinMethodName(method: o.BuiltinMethod): string { getBuiltinMethodName(method: o.BuiltinMethod): string {
var name: any /** TODO #9100 */; var name: string;
switch (method) { switch (method) {
case o.BuiltinMethod.ConcatArray: case o.BuiltinMethod.ConcatArray:
name = 'concat'; name = 'concat';

View File

@ -20,7 +20,7 @@ export class JavaScriptEmitter implements OutputEmitter {
var converter = new JsEmitterVisitor(moduleUrl); var converter = new JsEmitterVisitor(moduleUrl);
var ctx = EmitterVisitorContext.createRoot(exportedVars); var ctx = EmitterVisitorContext.createRoot(exportedVars);
converter.visitAllStatements(stmts, ctx); converter.visitAllStatements(stmts, ctx);
var srcParts: any[] /** TODO #9100 */ = []; var srcParts: string[] = [];
converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => { converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => {
// Note: can't write the real word for import as it screws up system.js auto detection... // Note: can't write the real word for import as it screws up system.js auto detection...
srcParts.push( srcParts.push(

View File

@ -416,7 +416,7 @@ export class LiteralArrayExpr extends Expression {
export class LiteralMapExpr extends Expression { export class LiteralMapExpr extends Expression {
public valueType: Type = null; public valueType: Type = null;
constructor(public entries: Array<Array<string|Expression>>, type: MapType = null) { constructor(public entries: [string, Expression][], type: MapType = null) {
super(type); super(type);
if (isPresent(type)) { if (isPresent(type)) {
this.valueType = type.valueType; this.valueType = type.valueType;
@ -673,9 +673,11 @@ export class ExpressionTransformer implements StatementVisitor, ExpressionVisito
visitLiteralArrayExpr(ast: LiteralArrayExpr, context: any): any { visitLiteralArrayExpr(ast: LiteralArrayExpr, context: any): any {
return new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context)); return new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context));
} }
visitLiteralMapExpr(ast: LiteralMapExpr, context: any): any { visitLiteralMapExpr(ast: LiteralMapExpr, context: any): any {
return new LiteralMapExpr(ast.entries.map( const entries = ast.entries.map(
(entry) => [entry[0], (<Expression>entry[1]).visitExpression(this, context)])); (entry): [string, Expression] => [entry[0], entry[1].visitExpression(this, context), ]);
return new LiteralMapExpr(entries);
} }
visitAllExpressions(exprs: Expression[], context: any): Expression[] { visitAllExpressions(exprs: Expression[], context: any): Expression[] {
return exprs.map(expr => expr.visitExpression(this, context)); return exprs.map(expr => expr.visitExpression(this, context));
@ -881,8 +883,7 @@ export function literalArr(values: Expression[], type: Type = null): LiteralArra
return new LiteralArrayExpr(values, type); return new LiteralArrayExpr(values, type);
} }
export function literalMap( export function literalMap(values: [string, Expression][], type: MapType = null): LiteralMapExpr {
values: Array<Array<string|Expression>>, type: MapType = null): LiteralMapExpr {
return new LiteralMapExpr(values, type); return new LiteralMapExpr(values, type);
} }

View File

@ -26,9 +26,9 @@ class JitEmitterVisitor extends AbstractJsEmitterVisitor {
private _evalArgValues: any[] = []; private _evalArgValues: any[] = [];
getArgs(): {[key: string]: any} { getArgs(): {[key: string]: any} {
var result = {}; var result: {[key: string]: any} = {};
for (var i = 0; i < this._evalArgNames.length; i++) { for (var i = 0; i < this._evalArgNames.length; i++) {
(result as any /** TODO #9100 */)[this._evalArgNames[i]] = this._evalArgValues[i]; result[this._evalArgNames[i]] = this._evalArgValues[i];
} }
return result; return result;
} }

View File

@ -46,7 +46,7 @@ export class TypeScriptEmitter implements OutputEmitter {
var converter = new _TsEmitterVisitor(moduleUrl); var converter = new _TsEmitterVisitor(moduleUrl);
var ctx = EmitterVisitorContext.createRoot(exportedVars); var ctx = EmitterVisitorContext.createRoot(exportedVars);
converter.visitAllStatements(stmts, ctx); converter.visitAllStatements(stmts, ctx);
var srcParts: any[] /** TODO #9100 */ = []; var srcParts: string[] = [];
converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => { converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => {
// Note: can't write the real word for import as it screws up system.js auto detection... // Note: can't write the real word for import as it screws up system.js auto detection...
srcParts.push( srcParts.push(
@ -243,7 +243,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
} }
visitBuiltintType(type: o.BuiltinType, ctx: EmitterVisitorContext): any { visitBuiltintType(type: o.BuiltinType, ctx: EmitterVisitorContext): any {
var typeStr: any /** TODO #9100 */; var typeStr: string;
switch (type.name) { switch (type.name) {
case o.BuiltinTypeName.Bool: case o.BuiltinTypeName.Bool:
typeStr = 'boolean'; typeStr = 'boolean';
@ -307,7 +307,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
} }
private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void { private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void {
this.visitAllObjects((param: any /** TODO #9100 */) => { this.visitAllObjects(param => {
ctx.print(param.name); ctx.print(param.name);
ctx.print(':'); ctx.print(':');
this.visitType(param.type, ctx); this.visitType(param.type, ctx);
@ -336,8 +336,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
} }
if (isPresent(typeParams) && typeParams.length > 0) { if (isPresent(typeParams) && typeParams.length > 0) {
ctx.print(`<`); ctx.print(`<`);
this.visitAllObjects( this.visitAllObjects(type => type.visitType(this, ctx), typeParams, ctx, ',');
(type: any /** TODO #9100 */) => type.visitType(this, ctx), typeParams, ctx, ',');
ctx.print(`>`); ctx.print(`>`);
} }
} }

View File

@ -22,7 +22,7 @@ class _ValueOutputAstTransformer implements ValueTransformer {
} }
visitStringMap(map: {[key: string]: any}, type: o.MapType): o.Expression { visitStringMap(map: {[key: string]: any}, type: o.MapType): o.Expression {
var entries: Array<string|o.Expression>[] = []; const entries: [string, o.Expression][] = [];
Object.keys(map).forEach(key => { entries.push([key, visitValue(map[key], this, null)]); }); Object.keys(map).forEach(key => { entries.push([key, visitValue(map[key], this, null)]); });
return o.literalMap(entries, type); return o.literalMap(entries, type);
} }

View File

@ -60,9 +60,8 @@ export class ValueTransformer implements ValueVisitor {
return arr.map(value => visitValue(value, this, context)); return arr.map(value => visitValue(value, this, context));
} }
visitStringMap(map: {[key: string]: any}, context: any): any { visitStringMap(map: {[key: string]: any}, context: any): any {
var result = {}; var result: {[key: string]: any} = {};
Object.keys(map).forEach( Object.keys(map).forEach(key => { result[key] = visitValue(map[key], this, context); });
key => { (result as any /** TODO #9100 */)[key] = visitValue(map[key], this, context); });
return result; return result;
} }
visitPrimitive(value: any, context: any): any { return value; } visitPrimitive(value: any, context: any): any { return value; }

View File

@ -64,7 +64,7 @@ export class CompileQuery {
return !this._values.values.some(value => value instanceof ViewQueryValues); return !this._values.values.some(value => value instanceof ViewQueryValues);
} }
afterChildren(targetStaticMethod: any /** TODO #9100 */, targetDynamicMethod: CompileMethod) { afterChildren(targetStaticMethod: CompileMethod, targetDynamicMethod: CompileMethod) {
var values = createQueryValues(this._values); var values = createQueryValues(this._values);
var updateStmts = [this.queryList.callMethod('reset', [o.literalArr(values)]).toStmt()]; var updateStmts = [this.queryList.callMethod('reset', [o.literalArr(values)]).toStmt()];
if (isPresent(this.ownerDirectiveExpression)) { if (isPresent(this.ownerDirectiveExpression)) {

View File

@ -169,16 +169,16 @@ export class CompileView implements NameResolver {
return proxyExpr.callFn(values); return proxyExpr.callFn(values);
} }
createLiteralMap(entries: Array<Array<string|o.Expression>>): o.Expression { createLiteralMap(entries: [string, o.Expression][]): o.Expression {
if (entries.length === 0) { if (entries.length === 0) {
return o.importExpr(resolveIdentifier(Identifiers.EMPTY_MAP)); return o.importExpr(resolveIdentifier(Identifiers.EMPTY_MAP));
} }
var proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`); const proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`);
var proxyParams: o.FnParam[] = []; const proxyParams: o.FnParam[] = [];
var proxyReturnEntries: Array<Array<string|o.Expression>> = []; const proxyReturnEntries: [string, o.Expression][] = [];
var values: o.Expression[] = []; const values: o.Expression[] = [];
for (var i = 0; i < entries.length; i++) { for (var i = 0; i < entries.length; i++) {
var paramName = `p${i}`; const paramName = `p${i}`;
proxyParams.push(new o.FnParam(paramName)); proxyParams.push(new o.FnParam(paramName));
proxyReturnEntries.push([entries[i][0], o.variable(paramName)]); proxyReturnEntries.push([entries[i][0], o.variable(paramName)]);
values.push(<o.Expression>entries[i][1]); values.push(<o.Expression>entries[i][1]);

View File

@ -46,7 +46,7 @@ export class CompileEventListener {
public eventPhase: string, listenerIndex: number) { public eventPhase: string, listenerIndex: number) {
this._method = new CompileMethod(compileElement.view); this._method = new CompileMethod(compileElement.view);
this._methodName = this._methodName =
`_handle_${santitizeEventName(eventName)}_${compileElement.nodeIndex}_${listenerIndex}`; `_handle_${sanitizeEventName(eventName)}_${compileElement.nodeIndex}_${listenerIndex}`;
this._eventParam = new o.FnParam( this._eventParam = new o.FnParam(
EventHandlerVars.event.name, EventHandlerVars.event.name,
o.importType(this.compileElement.view.genConfig.renderTypes.renderEvent)); o.importType(this.compileElement.view.genConfig.renderTypes.renderEvent));
@ -96,7 +96,7 @@ export class CompileEventListener {
} }
listenToRenderer() { listenToRenderer() {
var listenExpr: any /** TODO #9100 */; var listenExpr: o.Expression;
var eventListener = o.THIS_EXPR.callMethod( var eventListener = o.THIS_EXPR.callMethod(
'eventHandler', 'eventHandler',
[o.THIS_EXPR.prop(this._methodName).callMethod(o.BuiltinMethod.Bind, [o.THIS_EXPR])]); [o.THIS_EXPR.prop(this._methodName).callMethod(o.BuiltinMethod.Bind, [o.THIS_EXPR])]);
@ -148,13 +148,15 @@ export class CompileEventListener {
export function collectEventListeners( export function collectEventListeners(
hostEvents: BoundEventAst[], dirs: DirectiveAst[], hostEvents: BoundEventAst[], dirs: DirectiveAst[],
compileElement: CompileElement): CompileEventListener[] { compileElement: CompileElement): CompileEventListener[] {
var eventListeners: CompileEventListener[] = []; const eventListeners: CompileEventListener[] = [];
hostEvents.forEach((hostEvent) => { hostEvents.forEach((hostEvent) => {
compileElement.view.bindings.push(new CompileBinding(compileElement, hostEvent)); compileElement.view.bindings.push(new CompileBinding(compileElement, hostEvent));
var listener = CompileEventListener.getOrCreate( var listener = CompileEventListener.getOrCreate(
compileElement, hostEvent.target, hostEvent.name, hostEvent.phase, eventListeners); compileElement, hostEvent.target, hostEvent.name, hostEvent.phase, eventListeners);
listener.addAction(hostEvent, null, null); listener.addAction(hostEvent, null, null);
}); });
dirs.forEach((directiveAst) => { dirs.forEach((directiveAst) => {
var directiveInstance = var directiveInstance =
compileElement.instances.get(identifierToken(directiveAst.directive.type).reference); compileElement.instances.get(identifierToken(directiveAst.directive.type).reference);
@ -165,6 +167,7 @@ export function collectEventListeners(
listener.addAction(hostEvent, directiveAst.directive, directiveInstance); listener.addAction(hostEvent, directiveAst.directive, directiveInstance);
}); });
}); });
eventListeners.forEach((listener) => listener.finishMethod()); eventListeners.forEach((listener) => listener.finishMethod());
return eventListeners; return eventListeners;
} }
@ -174,6 +177,7 @@ export function bindDirectiveOutputs(
eventListeners: CompileEventListener[]) { eventListeners: CompileEventListener[]) {
Object.keys(directiveAst.directive.outputs).forEach(observablePropName => { Object.keys(directiveAst.directive.outputs).forEach(observablePropName => {
const eventName = directiveAst.directive.outputs[observablePropName]; const eventName = directiveAst.directive.outputs[observablePropName];
eventListeners.filter(listener => listener.eventName == eventName).forEach((listener) => { eventListeners.filter(listener => listener.eventName == eventName).forEach((listener) => {
listener.listenToDirective(directiveInstance, observablePropName); listener.listenToDirective(directiveInstance, observablePropName);
}); });
@ -199,6 +203,6 @@ function convertStmtIntoExpression(stmt: o.Statement): o.Expression {
return null; return null;
} }
function santitizeEventName(name: string): string { function sanitizeEventName(name: string): string {
return name.replace(/[^a-zA-Z_]/g, '_'); return name.replace(/[^a-zA-Z_]/g, '_');
} }

View File

@ -99,10 +99,9 @@ function bindAndWriteToRenderer(
view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileElement.nodeIndex, boundProp); view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileElement.nodeIndex, boundProp);
var fieldExpr = createBindFieldExpr(bindingIndex); var fieldExpr = createBindFieldExpr(bindingIndex);
var currValExpr = createCurrValueExpr(bindingIndex); var currValExpr = createCurrValueExpr(bindingIndex);
var renderMethod: string;
var oldRenderValue: o.Expression = sanitizedValue(boundProp, fieldExpr); var oldRenderValue: o.Expression = sanitizedValue(boundProp, fieldExpr);
var renderValue: o.Expression = sanitizedValue(boundProp, currValExpr); var renderValue: o.Expression = sanitizedValue(boundProp, currValExpr);
var updateStmts: any[] /** TODO #9100 */ = []; var updateStmts: o.Statement[] = [];
var compileMethod = view.detectChangesRenderPropertiesMethod; var compileMethod = view.detectChangesRenderPropertiesMethod;
switch (boundProp.type) { switch (boundProp.type) {
case PropertyBindingType.Property: case PropertyBindingType.Property:

View File

@ -57,7 +57,7 @@ export function getViewFactoryName(
} }
export function createFlatArray(expressions: o.Expression[]): o.Expression { export function createFlatArray(expressions: o.Expression[]): o.Expression {
var lastNonArrayExpressions: any[] /** TODO #9100 */ = []; var lastNonArrayExpressions: o.Expression[] = [];
var result: o.Expression = o.literalArr([]); var result: o.Expression = o.literalArr([]);
for (var i = 0; i < expressions.length; i++) { for (var i = 0; i < expressions.length; i++) {
var expr = expressions[i]; var expr = expressions[i];

View File

@ -511,10 +511,13 @@ function createViewFactory(
templateUrlInfo = view.component.template.templateUrl; templateUrlInfo = view.component.template.templateUrl;
} }
if (view.viewIndex === 0) { if (view.viewIndex === 0) {
var animationsExpr = o.literalMap(view.animations.map(entry => [entry.name, entry.fnExp])); var animationsExpr = o.literalMap(
initRenderCompTypeStmts = [new o.IfStmt( view.animations.map((entry): [string, o.Expression] => [entry.name, entry.fnExp]));
initRenderCompTypeStmts = [
new o.IfStmt(
renderCompTypeVar.identical(o.NULL_EXPR), renderCompTypeVar.identical(o.NULL_EXPR),
[renderCompTypeVar [
renderCompTypeVar
.set(ViewConstructorVars.viewUtils.callMethod( .set(ViewConstructorVars.viewUtils.callMethod(
'createRenderComponentType', 'createRenderComponentType',
[ [
@ -524,13 +527,16 @@ function createViewFactory(
view.styles, view.styles,
animationsExpr, animationsExpr,
])) ]))
.toStmt()])]; .toStmt(),
]),
];
} }
return o return o
.fn(viewFactoryArgs, initRenderCompTypeStmts.concat([new o.ReturnStatement( .fn(viewFactoryArgs, initRenderCompTypeStmts.concat([
o.variable(viewClass.name) new o.ReturnStatement(o.variable(viewClass.name)
.instantiate(viewClass.constructorMethod.params.map( .instantiate(viewClass.constructorMethod.params.map(
(param) => o.variable(param.name))))]), (param) => o.variable(param.name)))),
]),
o.importType(resolveIdentifier(Identifiers.AppView), [getContextType(view)])) o.importType(resolveIdentifier(Identifiers.AppView), [getContextType(view)]))
.toDeclStmt(view.viewFactory.name, [o.StmtModifier.Final]); .toDeclStmt(view.viewFactory.name, [o.StmtModifier.Final]);
} }

View File

@ -15,7 +15,7 @@ import {CompileMetadataResolver} from '../../src/metadata_resolver';
export function main() { export function main() {
describe('RuntimeAnimationCompiler', () => { describe('RuntimeAnimationCompiler', () => {
var resolver: any /** TODO #9100 */; var resolver: CompileMetadataResolver;
beforeEach( beforeEach(
inject([CompileMetadataResolver], (res: CompileMetadataResolver) => { resolver = res; })); inject([CompileMetadataResolver], (res: CompileMetadataResolver) => { resolver = res; }));

View File

@ -28,9 +28,9 @@ export function main() {
(keyframe: AnimationKeyframeAst): {[key: string]: string | number} => (keyframe: AnimationKeyframeAst): {[key: string]: string | number} =>
combineStyles(keyframe.styles); combineStyles(keyframe.styles);
var collectStepStyles = (step: AnimationStepAst): Array<{[key: string]: string | number}> => { var collectStepStyles = (step: AnimationStepAst): {[key: string]: string | number}[] => {
var keyframes = step.keyframes; var keyframes = step.keyframes;
var styles: any[] /** TODO #9100 */ = []; var styles: {[key: string]: string | number}[] = [];
if (step.startingStyles.styles.length > 0) { if (step.startingStyles.styles.length > 0) {
styles.push(combineStyles(step.startingStyles)); styles.push(combineStyles(step.startingStyles));
} }
@ -38,7 +38,7 @@ export function main() {
return styles; return styles;
}; };
var resolver: any /** TODO #9100 */; var resolver: CompileMetadataResolver;
beforeEach( beforeEach(
inject([CompileMetadataResolver], (res: CompileMetadataResolver) => { resolver = res; })); inject([CompileMetadataResolver], (res: CompileMetadataResolver) => { resolver = res; }));

View File

@ -275,7 +275,7 @@ export function main() {
it('should throw an error if a selector is being parsed while in the wrong mode', () => { it('should throw an error if a selector is being parsed while in the wrong mode', () => {
var cssCode = '.class > tag'; var cssCode = '.class > tag';
var capturedMessage: any /** TODO #9100 */; var capturedMessage: string;
try { try {
tokenize(cssCode, false, CssLexerMode.STYLE_BLOCK); tokenize(cssCode, false, CssLexerMode.STYLE_BLOCK);
} catch (e) { } catch (e) {
@ -298,7 +298,7 @@ export function main() {
describe('Attribute Mode', () => { describe('Attribute Mode', () => {
it('should consider attribute selectors as valid input and throw when an invalid modifier is used', it('should consider attribute selectors as valid input and throw when an invalid modifier is used',
() => { () => {
function tokenizeAttr(modifier: any /** TODO #9100 */) { function tokenizeAttr(modifier: string) {
var cssCode = 'value' + modifier + '=\'something\''; var cssCode = 'value' + modifier + '=\'something\'';
return tokenize(cssCode, false, CssLexerMode.ATTRIBUTE_SELECTOR); return tokenize(cssCode, false, CssLexerMode.ATTRIBUTE_SELECTOR);
} }

View File

@ -7,8 +7,8 @@
*/ */
import {hasLifecycleHook} from '@angular/compiler/src/lifecycle_reflector'; import {hasLifecycleHook} from '@angular/compiler/src/lifecycle_reflector';
import {LifecycleHooks} from '@angular/core/src/metadata/lifecycle_hooks'; import {SimpleChanges} from '@angular/core';
import {describe, expect, it} from '@angular/core/testing/testing_internal'; import {LifecycleHooks as Hooks} from '@angular/core/src/metadata/lifecycle_hooks';
export function main() { export function main() {
describe('Create Directive', () => { describe('Create Directive', () => {
@ -16,92 +16,81 @@ export function main() {
describe('ngOnChanges', () => { describe('ngOnChanges', () => {
it('should be true when the directive has the ngOnChanges method', () => { it('should be true when the directive has the ngOnChanges method', () => {
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveWithOnChangesMethod)) expect(hasLifecycleHook(Hooks.OnChanges, DirectiveWithOnChangesMethod)).toBe(true);
.toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise',
expect(hasLifecycleHook(LifecycleHooks.OnChanges, DirectiveNoHooks)).toBe(false); () => { expect(hasLifecycleHook(Hooks.OnChanges, DirectiveNoHooks)).toBe(false); });
});
}); });
describe('ngOnDestroy', () => { describe('ngOnDestroy', () => {
it('should be true when the directive has the ngOnDestroy method', () => { it('should be true when the directive has the ngOnDestroy method', () => {
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveWithOnDestroyMethod)) expect(hasLifecycleHook(Hooks.OnDestroy, DirectiveWithOnDestroyMethod)).toBe(true);
.toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise',
expect(hasLifecycleHook(LifecycleHooks.OnDestroy, DirectiveNoHooks)).toBe(false); () => { expect(hasLifecycleHook(Hooks.OnDestroy, DirectiveNoHooks)).toBe(false); });
});
}); });
describe('ngOnInit', () => { describe('ngOnInit', () => {
it('should be true when the directive has the ngOnInit method', () => { it('should be true when the directive has the ngOnInit method',
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveWithOnInitMethod)).toBe(true); () => { expect(hasLifecycleHook(Hooks.OnInit, DirectiveWithOnInitMethod)).toBe(true); });
});
it('should be false otherwise', () => { it('should be false otherwise',
expect(hasLifecycleHook(LifecycleHooks.OnInit, DirectiveNoHooks)).toBe(false); () => { expect(hasLifecycleHook(Hooks.OnInit, DirectiveNoHooks)).toBe(false); });
});
}); });
describe('ngDoCheck', () => { describe('ngDoCheck', () => {
it('should be true when the directive has the ngDoCheck method', () => { it('should be true when the directive has the ngDoCheck method', () => {
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveWithOnCheckMethod)).toBe(true); expect(hasLifecycleHook(Hooks.DoCheck, DirectiveWithOnCheckMethod)).toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise',
expect(hasLifecycleHook(LifecycleHooks.DoCheck, DirectiveNoHooks)).toBe(false); () => { expect(hasLifecycleHook(Hooks.DoCheck, DirectiveNoHooks)).toBe(false); });
});
}); });
describe('ngAfterContentInit', () => { describe('ngAfterContentInit', () => {
it('should be true when the directive has the ngAfterContentInit method', () => { it('should be true when the directive has the ngAfterContentInit method', () => {
expect(hasLifecycleHook( expect(hasLifecycleHook(Hooks.AfterContentInit, DirectiveWithAfterContentInitMethod))
LifecycleHooks.AfterContentInit, DirectiveWithAfterContentInitMethod))
.toBe(true); .toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise', () => {
expect(hasLifecycleHook(LifecycleHooks.AfterContentInit, DirectiveNoHooks)).toBe(false); expect(hasLifecycleHook(Hooks.AfterContentInit, DirectiveNoHooks)).toBe(false);
}); });
}); });
describe('ngAfterContentChecked', () => { describe('ngAfterContentChecked', () => {
it('should be true when the directive has the ngAfterContentChecked method', () => { it('should be true when the directive has the ngAfterContentChecked method', () => {
expect(hasLifecycleHook( expect(
LifecycleHooks.AfterContentChecked, DirectiveWithAfterContentCheckedMethod)) hasLifecycleHook(Hooks.AfterContentChecked, DirectiveWithAfterContentCheckedMethod))
.toBe(true); .toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise', () => {
expect(hasLifecycleHook(LifecycleHooks.AfterContentChecked, DirectiveNoHooks)) expect(hasLifecycleHook(Hooks.AfterContentChecked, DirectiveNoHooks)).toBe(false);
.toBe(false);
}); });
}); });
describe('ngAfterViewInit', () => { describe('ngAfterViewInit', () => {
it('should be true when the directive has the ngAfterViewInit method', () => { it('should be true when the directive has the ngAfterViewInit method', () => {
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveWithAfterViewInitMethod)) expect(hasLifecycleHook(Hooks.AfterViewInit, DirectiveWithAfterViewInitMethod))
.toBe(true); .toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise',
expect(hasLifecycleHook(LifecycleHooks.AfterViewInit, DirectiveNoHooks)).toBe(false); () => { expect(hasLifecycleHook(Hooks.AfterViewInit, DirectiveNoHooks)).toBe(false); });
});
}); });
describe('ngAfterViewChecked', () => { describe('ngAfterViewChecked', () => {
it('should be true when the directive has the ngAfterViewChecked method', () => { it('should be true when the directive has the ngAfterViewChecked method', () => {
expect(hasLifecycleHook( expect(hasLifecycleHook(Hooks.AfterViewChecked, DirectiveWithAfterViewCheckedMethod))
LifecycleHooks.AfterViewChecked, DirectiveWithAfterViewCheckedMethod))
.toBe(true); .toBe(true);
}); });
it('should be false otherwise', () => { it('should be false otherwise', () => {
expect(hasLifecycleHook(LifecycleHooks.AfterViewChecked, DirectiveNoHooks)).toBe(false); expect(hasLifecycleHook(Hooks.AfterViewChecked, DirectiveNoHooks)).toBe(false);
}); });
}); });
}); });
@ -111,7 +100,7 @@ export function main() {
class DirectiveNoHooks {} class DirectiveNoHooks {}
class DirectiveWithOnChangesMethod { class DirectiveWithOnChangesMethod {
ngOnChanges(_: any /** TODO #9100 */) {} ngOnChanges(_: SimpleChanges) {}
} }
class DirectiveWithOnInitMethod { class DirectiveWithOnInitMethod {

View File

@ -43,7 +43,7 @@ export function main() {
describe('output emitter', () => { describe('output emitter', () => {
outputDefs.forEach((outputDef) => { outputDefs.forEach((outputDef) => {
describe(`${outputDef['name']}`, () => { describe(`${outputDef['name']}`, () => {
var expressions: any /** TODO #9100 */; var expressions: {[k: string]: any};
beforeEach(() => { expressions = outputDef['getExpressions']()(); }); beforeEach(() => { expressions = outputDef['getExpressions']()(); });
it('should support literals', () => { it('should support literals', () => {
@ -109,13 +109,16 @@ export function main() {
}); });
describe('operators', () => { describe('operators', () => {
var ops: any /** TODO #9100 */; var ops: {[k: string]: Function};
var aObj: any /** TODO #9100 */, bObj: any /** TODO #9100 */; var aObj: any;
var bObj: any;
beforeEach(() => { beforeEach(() => {
ops = expressions['operators']; ops = expressions['operators'];
aObj = new Object(); aObj = {};
bObj = new Object(); bObj = {};
}); });
it('should support ==', () => { it('should support ==', () => {
expect(ops['=='](aObj, aObj)).toBe(true); expect(ops['=='](aObj, aObj)).toBe(true);
expect(ops['=='](aObj, bObj)).toBe(false); expect(ops['=='](aObj, bObj)).toBe(false);

View File

@ -53,7 +53,7 @@ export function main() {
it('should return an error from the definitions', it('should return an error from the definitions',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo'; var url = '/foo';
var response: any /** TODO #9100 */ = null; var response: string = null;
resourceLoader.when(url, response); resourceLoader.when(url, response);
expectResponse(resourceLoader.get(url), url, response, () => async.done()); expectResponse(resourceLoader.get(url), url, response, () => async.done());
resourceLoader.flush(); resourceLoader.flush();
@ -71,7 +71,7 @@ export function main() {
it('should return an error from the expectations', it('should return an error from the expectations',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
var url = '/foo'; var url = '/foo';
var response: any /** TODO #9100 */ = null; var response: string = null;
resourceLoader.expect(url, response); resourceLoader.expect(url, response);
expectResponse(resourceLoader.get(url), url, response, () => async.done()); expectResponse(resourceLoader.get(url), url, response, () => async.done());
resourceLoader.flush(); resourceLoader.flush();

View File

@ -11,7 +11,7 @@ import {UrlResolver} from '@angular/compiler/src/url_resolver';
export function main() { export function main() {
describe('extractStyleUrls', () => { describe('extractStyleUrls', () => {
var urlResolver: any /** TODO #9100 */; var urlResolver: UrlResolver;
beforeEach(() => { urlResolver = new UrlResolver(); }); beforeEach(() => { urlResolver = new UrlResolver(); });

View File

@ -1146,7 +1146,7 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
}); });
describe('content projection', () => { describe('content projection', () => {
var compCounter: any /** TODO #9100 */; var compCounter: number;
beforeEach(() => { compCounter = 0; }); beforeEach(() => { compCounter = 0; });
function createComp( function createComp(

View File

@ -67,7 +67,7 @@ export class MockResourceLoader extends ResourceLoader {
verifyNoOutstandingExpectations() { verifyNoOutstandingExpectations() {
if (this._expectations.length === 0) return; if (this._expectations.length === 0) return;
var urls: any[] /** TODO #9100 */ = []; var urls: string[] = [];
for (var i = 0; i < this._expectations.length; i++) { for (var i = 0; i < this._expectations.length; i++) {
var expectation = this._expectations[i]; var expectation = this._expectations[i];
urls.push(expectation.url); urls.push(expectation.url);

View File

@ -78,14 +78,14 @@ export class EventEmitter<T> extends Subject<T> {
emit(value?: T) { super.next(value); } emit(value?: T) { super.next(value); }
subscribe(generatorOrNext?: any, error?: any, complete?: any): any { subscribe(generatorOrNext?: any, error?: any, complete?: any): any {
let schedulerFn: any /** TODO #9100 */; let schedulerFn: (t: any) => any;
let errorFn = (err: any): any /** TODO #9100 */ => null; let errorFn = (err: any): any => null;
let completeFn = (): any /** TODO #9100 */ => null; let completeFn = (): any => null;
if (generatorOrNext && typeof generatorOrNext === 'object') { if (generatorOrNext && typeof generatorOrNext === 'object') {
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => { schedulerFn = this.__isAsync ? (value: any) => {
setTimeout(() => generatorOrNext.next(value)); setTimeout(() => generatorOrNext.next(value));
} : (value: any /** TODO #9100 */) => { generatorOrNext.next(value); }; } : (value: any) => { generatorOrNext.next(value); };
if (generatorOrNext.error) { if (generatorOrNext.error) {
errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } : errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
@ -97,9 +97,8 @@ export class EventEmitter<T> extends Subject<T> {
() => { generatorOrNext.complete(); }; () => { generatorOrNext.complete(); };
} }
} else { } else {
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => { schedulerFn = this.__isAsync ? (value: any) => { setTimeout(() => generatorOrNext(value)); } :
setTimeout(() => generatorOrNext(value)); (value: any) => { generatorOrNext(value); };
} : (value: any /** TODO #9100 */) => { generatorOrNext(value); };
if (error) { if (error) {
errorFn = errorFn =