From 96c93260a2b40c62f93f5ae8a7d1faf2d6eaecd9 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 7 Jun 2021 17:10:51 +0200 Subject: [PATCH] refactor(compiler): ensure compatibility with noImplicitOverride (#42512) Adds the `override` keyword to the `compiler` sources to ensure compatibility with `noImplicitOverride`. PR Close #42512 --- .../src/aot/static_symbol_resolver.ts | 2 +- .../compiler/src/aot/summary_serializer.ts | 6 +-- .../compiler/src/compiler_facade_interface.ts | 4 +- .../src/compiler_util/expression_converter.ts | 8 ++-- .../compiler/src/expression_parser/ast.ts | 22 ++++----- .../compiler/src/expression_parser/parser.ts | 4 +- packages/compiler/src/i18n/digest.ts | 2 +- packages/compiler/src/i18n/message_bundle.ts | 8 ++-- .../src/i18n/serializers/serializer.ts | 8 ++-- packages/compiler/src/i18n/serializers/xmb.ts | 2 +- packages/compiler/src/i18n/serializers/xtb.ts | 2 +- packages/compiler/src/metadata_resolver.ts | 2 +- .../compiler/src/ml_parser/html_parser.ts | 2 +- packages/compiler/src/ml_parser/lexer.ts | 8 ++-- packages/compiler/src/ml_parser/xml_parser.ts | 2 +- .../src/output/abstract_js_emitter.ts | 11 +++-- packages/compiler/src/output/js_emitter.ts | 6 +-- packages/compiler/src/output/output_ast.ts | 14 +++--- packages/compiler/src/output/output_jit.ts | 8 ++-- packages/compiler/src/output/ts_emitter.ts | 10 ++-- .../compiler/src/render3/view/t2_binder.ts | 18 ++++---- .../compiler/src/render3/view/template.ts | 6 +-- packages/compiler/src/resource_loader.ts | 13 +++--- .../src/template_parser/binding_parser.ts | 2 +- .../src/template_parser/template_ast.ts | 6 +-- .../compiler/test/directive_resolver_spec.ts | 14 +++--- .../test/expression_parser/ast_spec.ts | 2 +- .../test/expression_parser/utils/unparser.ts | 2 +- .../test/expression_parser/utils/validator.ts | 44 +++++++++--------- .../test/i18n/serializers/i18n_ast_spec.ts | 6 +-- .../compiler/test/render3/util/expression.ts | 44 +++++++++--------- .../compiler/test/style_url_resolver_spec.ts | 2 +- .../template_parser/template_parser_spec.ts | 28 +++++------ .../test/template_parser/util/expression.ts | 46 +++++++++---------- .../testing/src/directive_resolver_mock.ts | 8 ++-- .../testing/src/ng_module_resolver_mock.ts | 2 +- .../testing/src/pipe_resolver_mock.ts | 2 +- 37 files changed, 191 insertions(+), 185 deletions(-) diff --git a/packages/compiler/src/aot/static_symbol_resolver.ts b/packages/compiler/src/aot/static_symbol_resolver.ts index 9b06465c2c..4389e6c293 100644 --- a/packages/compiler/src/aot/static_symbol_resolver.ts +++ b/packages/compiler/src/aot/static_symbol_resolver.ts @@ -396,7 +396,7 @@ export class StaticSymbolResolver { const self = this; class ReferenceTransformer extends ValueTransformer { - visitStringMap(map: {[key: string]: any}, functionParams: string[]): any { + override visitStringMap(map: {[key: string]: any}, functionParams: string[]): any { const symbolic = map['__symbolic']; if (symbolic === 'function') { const oldLen = functionParams.length; diff --git a/packages/compiler/src/aot/summary_serializer.ts b/packages/compiler/src/aot/summary_serializer.ts index 956910f311..fb7523da5e 100644 --- a/packages/compiler/src/aot/summary_serializer.ts +++ b/packages/compiler/src/aot/summary_serializer.ts @@ -234,7 +234,7 @@ class ToJsonSerializer extends ValueTransformer { return visitValue(value, this, flags); } - visitOther(value: any, context: any): any { + override visitOther(value: any, context: any): any { if (value instanceof StaticSymbol) { let baseSymbol = this.symbolResolver.getStaticSymbol(value.filePath, value.name); const index = this.visitStaticSymbol(baseSymbol, context); @@ -249,7 +249,7 @@ class ToJsonSerializer extends ValueTransformer { * TODO: find out a way to have line and character numbers in errors without * excessive recompilation in bazel. */ - visitStringMap(map: {[key: string]: any}, context: any): any { + override visitStringMap(map: {[key: string]: any}, context: any): any { if (map['__symbolic'] === 'resolved') { return visitValue(map['symbol'], this, context); } @@ -481,7 +481,7 @@ class FromJsonDeserializer extends ValueTransformer { return {moduleName: data.moduleName, summaries, importAs: allImportAs}; } - visitStringMap(map: {[key: string]: any}, context: any): any { + override visitStringMap(map: {[key: string]: any}, context: any): any { if ('__symbol' in map) { const baseSymbol = this.symbols[map['__symbol']]; const members = map['members']; diff --git a/packages/compiler/src/compiler_facade_interface.ts b/packages/compiler/src/compiler_facade_interface.ts index 3bfb7d2fc1..14ac1a341b 100644 --- a/packages/compiler/src/compiler_facade_interface.ts +++ b/packages/compiler/src/compiler_facade_interface.ts @@ -63,7 +63,9 @@ export interface CompilerFacade { createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; FactoryTarget: typeof FactoryTarget; - ResourceLoader: {new(): ResourceLoader}; + // Note that we do not use `{new(): ResourceLoader}` here because + // the resource loader class is abstract and not constructable. + ResourceLoader: Function&{prototype: ResourceLoader}; } export interface CoreEnvironment { diff --git a/packages/compiler/src/compiler_util/expression_converter.ts b/packages/compiler/src/compiler_util/expression_converter.ts index 6911c6d981..1571068807 100644 --- a/packages/compiler/src/compiler_util/expression_converter.ts +++ b/packages/compiler/src/compiler_util/expression_converter.ts @@ -300,19 +300,19 @@ class _BuiltinAstConverter extends cdAst.AstTransformer { constructor(private _converterFactory: BuiltinConverterFactory) { super(); } - visitPipe(ast: cdAst.BindingPipe, context: any): any { + override visitPipe(ast: cdAst.BindingPipe, context: any): any { const args = [ast.exp, ...ast.args].map(ast => ast.visit(this, context)); return new BuiltinFunctionCall( ast.span, ast.sourceSpan, args, this._converterFactory.createPipeConverter(ast.name, args.length)); } - visitLiteralArray(ast: cdAst.LiteralArray, context: any): any { + override visitLiteralArray(ast: cdAst.LiteralArray, context: any): any { const args = ast.expressions.map(ast => ast.visit(this, context)); return new BuiltinFunctionCall( ast.span, ast.sourceSpan, args, this._converterFactory.createLiteralArrayConverter(ast.expressions.length)); } - visitLiteralMap(ast: cdAst.LiteralMap, context: any): any { + override visitLiteralMap(ast: cdAst.LiteralMap, context: any): any { const args = ast.values.map(ast => ast.visit(this, context)); return new BuiltinFunctionCall( @@ -1016,7 +1016,7 @@ function convertStmtIntoExpression(stmt: o.Statement): o.Expression|null { export class BuiltinFunctionCall extends cdAst.FunctionCall { constructor( - span: cdAst.ParseSpan, sourceSpan: cdAst.AbsoluteSourceSpan, public args: cdAst.AST[], + span: cdAst.ParseSpan, sourceSpan: cdAst.AbsoluteSourceSpan, args: cdAst.AST[], public converter: BuiltinConverter) { super(span, sourceSpan, null, args); } diff --git a/packages/compiler/src/expression_parser/ast.ts b/packages/compiler/src/expression_parser/ast.ts index 51b5ced0e7..50bac87750 100644 --- a/packages/compiler/src/expression_parser/ast.ts +++ b/packages/compiler/src/expression_parser/ast.ts @@ -24,16 +24,16 @@ export class ParseSpan { } } -export class AST { +export abstract class AST { constructor( public span: ParseSpan, /** * Absolute location of the expression AST in a source code file. */ public sourceSpan: AbsoluteSourceSpan) {} - visit(visitor: AstVisitor, context: any = null): any { - return null; - } + + abstract visit(visitor: AstVisitor, context?: any): any; + toString(): string { return 'AST'; } @@ -68,7 +68,7 @@ export class Quote extends AST { visit(visitor: AstVisitor, context: any = null): any { return visitor.visitQuote(this, context); } - toString(): string { + override toString(): string { return 'Quote'; } } @@ -94,7 +94,7 @@ export class ImplicitReceiver extends AST { * TODO: we should find a way for this class not to extend from `ImplicitReceiver` in the future. */ export class ThisReceiver extends ImplicitReceiver { - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { return visitor.visitThisReceiver?.(this, context); } } @@ -260,9 +260,9 @@ export class Binary extends AST { export class Unary extends Binary { // Redeclare the properties that are inherited from `Binary` as `never`, as consumers should not // depend on these fields when operating on `Unary`. - left: never; - right: never; - operation: never; + override left: never; + override right: never; + override operation: never; /** * Creates a unary minus expression "-x", represented as `Binary` using "0 - x". @@ -290,7 +290,7 @@ export class Unary extends Binary { super(span, sourceSpan, binaryOp, binaryLeft, binaryRight); } - visit(visitor: AstVisitor, context: any = null): any { + override visit(visitor: AstVisitor, context: any = null): any { if (visitor.visitUnary !== undefined) { return visitor.visitUnary(this, context); } @@ -374,7 +374,7 @@ export class ASTWithSource extends AST { } return this.ast.visit(visitor, context); } - toString(): string { + override toString(): string { return `${this.source} in ${this.location}`; } } diff --git a/packages/compiler/src/expression_parser/parser.ts b/packages/compiler/src/expression_parser/parser.ts index 66e5bc2c06..7fc84c14ae 100644 --- a/packages/compiler/src/expression_parser/parser.ts +++ b/packages/compiler/src/expression_parser/parser.ts @@ -367,7 +367,7 @@ export class Parser { } export class IvyParser extends Parser { - simpleExpressionChecker = IvySimpleExpressionChecker; + override simpleExpressionChecker = IvySimpleExpressionChecker; } /** Describes a stateful context an expression parser is in. */ @@ -1371,7 +1371,7 @@ class SimpleExpressionChecker implements AstVisitor { class IvySimpleExpressionChecker extends RecursiveAstVisitor implements SimpleExpressionChecker { errors: string[] = []; - visitPipe() { + override visitPipe() { this.errors.push('pipes'); } } diff --git a/packages/compiler/src/i18n/digest.ts b/packages/compiler/src/i18n/digest.ts index 64afb7adaa..5134fe749c 100644 --- a/packages/compiler/src/i18n/digest.ts +++ b/packages/compiler/src/i18n/digest.ts @@ -93,7 +93,7 @@ export function serializeNodes(nodes: i18n.Node[]): string[] { * @internal */ class _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor { - visitIcu(icu: i18n.Icu, context: any): any { + override visitIcu(icu: i18n.Icu, context: any): any { let strCases = Object.keys(icu.cases).map((k: string) => `${k} {${icu.cases[k].visit(this)}}`); // Do not take the expression into account return `{${icu.type}, ${strCases.join(', ')}}`; diff --git a/packages/compiler/src/i18n/message_bundle.ts b/packages/compiler/src/i18n/message_bundle.ts index b3fa589538..3bf6d90a98 100644 --- a/packages/compiler/src/i18n/message_bundle.ts +++ b/packages/compiler/src/i18n/message_bundle.ts @@ -89,7 +89,8 @@ class MapPlaceholderNames extends i18n.CloneVisitor { return mapper ? nodes.map(n => n.visit(this, mapper)) : nodes; } - visitTagPlaceholder(ph: i18n.TagPlaceholder, mapper: PlaceholderMapper): i18n.TagPlaceholder { + override visitTagPlaceholder(ph: i18n.TagPlaceholder, mapper: PlaceholderMapper): + i18n.TagPlaceholder { const startName = mapper.toPublicName(ph.startName)!; const closeName = ph.closeName ? mapper.toPublicName(ph.closeName)! : ph.closeName; const children = ph.children.map(n => n.visit(this, mapper)); @@ -98,11 +99,12 @@ class MapPlaceholderNames extends i18n.CloneVisitor { ph.startSourceSpan, ph.endSourceSpan); } - visitPlaceholder(ph: i18n.Placeholder, mapper: PlaceholderMapper): i18n.Placeholder { + override visitPlaceholder(ph: i18n.Placeholder, mapper: PlaceholderMapper): i18n.Placeholder { return new i18n.Placeholder(ph.value, mapper.toPublicName(ph.name)!, ph.sourceSpan); } - visitIcuPlaceholder(ph: i18n.IcuPlaceholder, mapper: PlaceholderMapper): i18n.IcuPlaceholder { + override visitIcuPlaceholder(ph: i18n.IcuPlaceholder, mapper: PlaceholderMapper): + i18n.IcuPlaceholder { return new i18n.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name)!, ph.sourceSpan); } } diff --git a/packages/compiler/src/i18n/serializers/serializer.ts b/packages/compiler/src/i18n/serializers/serializer.ts index d8c02f607a..effcfa6091 100644 --- a/packages/compiler/src/i18n/serializers/serializer.ts +++ b/packages/compiler/src/i18n/serializers/serializer.ts @@ -63,21 +63,21 @@ export class SimplePlaceholderMapper extends i18n.RecurseVisitor implements Plac null; } - visitText(text: i18n.Text, context?: any): any { + override visitText(text: i18n.Text, context?: any): any { return null; } - visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): any { + override visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): any { this.visitPlaceholderName(ph.startName); super.visitTagPlaceholder(ph, context); this.visitPlaceholderName(ph.closeName); } - visitPlaceholder(ph: i18n.Placeholder, context?: any): any { + override visitPlaceholder(ph: i18n.Placeholder, context?: any): any { this.visitPlaceholderName(ph.name); } - visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any { + override visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any { this.visitPlaceholderName(ph.name); } diff --git a/packages/compiler/src/i18n/serializers/xmb.ts b/packages/compiler/src/i18n/serializers/xmb.ts index 591bdbf8a6..50d3a94754 100644 --- a/packages/compiler/src/i18n/serializers/xmb.ts +++ b/packages/compiler/src/i18n/serializers/xmb.ts @@ -90,7 +90,7 @@ export class Xmb extends Serializer { } - createNameMapper(message: i18n.Message): PlaceholderMapper { + override createNameMapper(message: i18n.Message): PlaceholderMapper { return new SimplePlaceholderMapper(message, toPublicName); } } diff --git a/packages/compiler/src/i18n/serializers/xtb.ts b/packages/compiler/src/i18n/serializers/xtb.ts index ed7eab95f1..866a04b9f8 100644 --- a/packages/compiler/src/i18n/serializers/xtb.ts +++ b/packages/compiler/src/i18n/serializers/xtb.ts @@ -58,7 +58,7 @@ export class Xtb extends Serializer { return digest(message); } - createNameMapper(message: i18n.Message): PlaceholderMapper { + override createNameMapper(message: i18n.Message): PlaceholderMapper { return new SimplePlaceholderMapper(message, toPublicName); } } diff --git a/packages/compiler/src/metadata_resolver.ts b/packages/compiler/src/metadata_resolver.ts index 00315c77f5..0bf9de3709 100644 --- a/packages/compiler/src/metadata_resolver.ts +++ b/packages/compiler/src/metadata_resolver.ts @@ -1268,7 +1268,7 @@ function extractIdentifiers(value: any, targetIdentifiers: cpl.CompileIdentifier } class _CompileValueConverter extends ValueTransformer { - visitOther(value: any, targetIdentifiers: cpl.CompileIdentifierMetadata[]): any { + override visitOther(value: any, targetIdentifiers: cpl.CompileIdentifierMetadata[]): any { targetIdentifiers.push({reference: value}); } } diff --git a/packages/compiler/src/ml_parser/html_parser.ts b/packages/compiler/src/ml_parser/html_parser.ts index 9a9d507545..5589d6d1c4 100644 --- a/packages/compiler/src/ml_parser/html_parser.ts +++ b/packages/compiler/src/ml_parser/html_parser.ts @@ -17,7 +17,7 @@ export class HtmlParser extends Parser { super(getHtmlTagDefinition); } - parse(source: string, url: string, options?: TokenizeOptions): ParseTreeResult { + override parse(source: string, url: string, options?: TokenizeOptions): ParseTreeResult { return super.parse(source, url, options); } } diff --git a/packages/compiler/src/ml_parser/lexer.ts b/packages/compiler/src/ml_parser/lexer.ts index 8d832f4d2a..5771b09263 100644 --- a/packages/compiler/src/ml_parser/lexer.ts +++ b/packages/compiler/src/ml_parser/lexer.ts @@ -1006,22 +1006,22 @@ class EscapedCharacterCursor extends PlainCharacterCursor { } } - advance(): void { + override advance(): void { this.state = this.internalState; super.advance(); this.processEscapeSequence(); } - init(): void { + override init(): void { super.init(); this.processEscapeSequence(); } - clone(): EscapedCharacterCursor { + override clone(): EscapedCharacterCursor { return new EscapedCharacterCursor(this); } - getChars(start: this): string { + override getChars(start: this): string { const cursor = start.clone(); let chars = ''; while (cursor.internalState.offset < this.internalState.offset) { diff --git a/packages/compiler/src/ml_parser/xml_parser.ts b/packages/compiler/src/ml_parser/xml_parser.ts index d87ac19ee2..78f40ab727 100644 --- a/packages/compiler/src/ml_parser/xml_parser.ts +++ b/packages/compiler/src/ml_parser/xml_parser.ts @@ -17,7 +17,7 @@ export class XmlParser extends Parser { super(getXmlTagDefinition); } - parse(source: string, url: string, options?: TokenizeOptions): ParseTreeResult { + override parse(source: string, url: string, options?: TokenizeOptions): ParseTreeResult { return super.parse(source, url, options); } } diff --git a/packages/compiler/src/output/abstract_js_emitter.ts b/packages/compiler/src/output/abstract_js_emitter.ts index b0054f02db..7ce1e95527 100644 --- a/packages/compiler/src/output/abstract_js_emitter.ts +++ b/packages/compiler/src/output/abstract_js_emitter.ts @@ -87,11 +87,11 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ctx.println(stmt, `};`); } - visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any { + override visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any { throw new Error('Cannot emit a WrappedNodeExpr in Javascript.'); } - visitReadVarExpr(ast: o.ReadVarExpr, ctx: EmitterVisitorContext): string|null { + override visitReadVarExpr(ast: o.ReadVarExpr, ctx: EmitterVisitorContext): string|null { if (ast.builtin === o.BuiltinVar.This) { ctx.print(ast, 'self'); } else if (ast.builtin === o.BuiltinVar.Super) { @@ -115,7 +115,8 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { ast.value.visitExpression(this, ctx); return null; } - visitInvokeFunctionExpr(expr: o.InvokeFunctionExpr, ctx: EmitterVisitorContext): string|null { + override visitInvokeFunctionExpr(expr: o.InvokeFunctionExpr, ctx: EmitterVisitorContext): string + |null { const fnExpr = expr.fn; if (fnExpr instanceof o.ReadVarExpr && fnExpr.builtin === o.BuiltinVar.Super) { ctx.currentClass!.parent!.visitExpression(this, ctx); @@ -130,7 +131,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { } return null; } - visitTaggedTemplateExpr(ast: o.TaggedTemplateExpr, ctx: EmitterVisitorContext): any { + override visitTaggedTemplateExpr(ast: o.TaggedTemplateExpr, ctx: EmitterVisitorContext): any { // The following convoluted piece of code is effectively the downlevelled equivalent of // ``` // tag`...` @@ -188,7 +189,7 @@ export abstract class AbstractJsEmitterVisitor extends AbstractEmitterVisitor { return null; } - visitLocalizedString(ast: o.LocalizedString, ctx: EmitterVisitorContext): any { + override visitLocalizedString(ast: o.LocalizedString, ctx: EmitterVisitorContext): any { // The following convoluted piece of code is effectively the downlevelled equivalent of // ``` // $localize `...` diff --git a/packages/compiler/src/output/js_emitter.ts b/packages/compiler/src/output/js_emitter.ts index 130a22251f..aa325a2155 100644 --- a/packages/compiler/src/output/js_emitter.ts +++ b/packages/compiler/src/output/js_emitter.ts @@ -54,21 +54,21 @@ class JsEmitterVisitor extends AbstractJsEmitterVisitor { ctx.print(ast, name!); return null; } - visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { + override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { super.visitDeclareVarStmt(stmt, ctx); if (stmt.hasModifier(o.StmtModifier.Exported)) { ctx.println(stmt, exportVar(stmt.name)); } return null; } - visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { + override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { super.visitDeclareFunctionStmt(stmt, ctx); if (stmt.hasModifier(o.StmtModifier.Exported)) { ctx.println(stmt, exportVar(stmt.name)); } return null; } - visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { + override visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { super.visitDeclareClassStmt(stmt, ctx); if (stmt.hasModifier(o.StmtModifier.Exported)) { ctx.println(stmt, exportVar(stmt.name)); diff --git a/packages/compiler/src/output/output_ast.ts b/packages/compiler/src/output/output_ast.ts index 4faa216c8f..eccfd35dab 100644 --- a/packages/compiler/src/output/output_ast.ts +++ b/packages/compiler/src/output/output_ast.ts @@ -1050,7 +1050,7 @@ export class JSDocComment extends LeadingComment { constructor(public tags: JSDocTag[]) { super('', /* multiline */ true, /* trailingNewline */ true); } - toString(): string { + override toString(): string { return serializeTags(this.tags); } } @@ -1726,15 +1726,15 @@ export function findReadVarNames(stmts: Statement[]): Set { class _ReadVarVisitor extends RecursiveAstVisitor { varNames = new Set(); - visitDeclareFunctionStmt(stmt: DeclareFunctionStmt, context: any): any { + override visitDeclareFunctionStmt(stmt: DeclareFunctionStmt, context: any): any { // Don't descend into nested functions return stmt; } - visitDeclareClassStmt(stmt: ClassStmt, context: any): any { + override visitDeclareClassStmt(stmt: ClassStmt, context: any): any { // Don't descend into nested classes return stmt; } - visitReadVarExpr(ast: ReadVarExpr, context: any): any { + override visitReadVarExpr(ast: ReadVarExpr, context: any): any { if (ast.name) { this.varNames.add(ast.name); } @@ -1750,7 +1750,7 @@ export function collectExternalReferences(stmts: Statement[]): ExternalReference class _FindExternalReferencesVisitor extends RecursiveAstVisitor { externalReferences: ExternalReference[] = []; - visitExternalExpr(e: ExternalExpr, context: any) { + override visitExternalExpr(e: ExternalExpr, context: any) { this.externalReferences.push(e.value); return super.visitExternalExpr(e, context); } @@ -1786,7 +1786,7 @@ class _ApplySourceSpanTransformer extends AstTransformer { return clone; } - transformExpr(expr: Expression, context: any): Expression { + override transformExpr(expr: Expression, context: any): Expression { if (!expr.sourceSpan) { expr = this._clone(expr); expr.sourceSpan = this.sourceSpan; @@ -1794,7 +1794,7 @@ class _ApplySourceSpanTransformer extends AstTransformer { return expr; } - transformStmt(stmt: Statement, context: any): Statement { + override transformStmt(stmt: Statement, context: any): Statement { if (!stmt.sourceSpan) { stmt = this._clone(stmt); stmt.sourceSpan = this.sourceSpan; diff --git a/packages/compiler/src/output/output_jit.ts b/packages/compiler/src/output/output_jit.ts index d672098bca..0923e91bee 100644 --- a/packages/compiler/src/output/output_jit.ts +++ b/packages/compiler/src/output/output_jit.ts @@ -124,26 +124,26 @@ export class JitEmitterVisitor extends AbstractJsEmitterVisitor { return null; } - visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any { + override visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): any { this._emitReferenceToExternal(ast, ast.node, ctx); return null; } - visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { + override visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any { if (stmt.hasModifier(o.StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } return super.visitDeclareVarStmt(stmt, ctx); } - visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { + override visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any { if (stmt.hasModifier(o.StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } return super.visitDeclareFunctionStmt(stmt, ctx); } - visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { + override visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any { if (stmt.hasModifier(o.StmtModifier.Exported)) { this._evalExportedVars.push(stmt.name); } diff --git a/packages/compiler/src/output/ts_emitter.ts b/packages/compiler/src/output/ts_emitter.ts index 968e0ea42f..e7cad7060e 100644 --- a/packages/compiler/src/output/ts_emitter.ts +++ b/packages/compiler/src/output/ts_emitter.ts @@ -93,7 +93,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor } } - visitLiteralExpr(ast: o.LiteralExpr, ctx: EmitterVisitorContext): any { + override visitLiteralExpr(ast: o.LiteralExpr, ctx: EmitterVisitorContext): any { const value = ast.value; if (value == null && ast.type != o.INFERRED_TYPE) { ctx.print(ast, `(${value} as any)`); @@ -107,7 +107,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor // In SNC mode, [] have the type never[], so we cast here to any[]. // TODO: narrow the cast to a more explicit type, or use a pattern that does not // start with [].concat. see https://github.com/angular/angular/pull/11846 - visitLiteralArrayExpr(ast: o.LiteralArrayExpr, ctx: EmitterVisitorContext): any { + override visitLiteralArrayExpr(ast: o.LiteralArrayExpr, ctx: EmitterVisitorContext): any { if (ast.entries.length === 0) { ctx.print(ast, '('); } @@ -123,7 +123,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitAssertNotNullExpr(ast: o.AssertNotNull, ctx: EmitterVisitorContext): any { + override visitAssertNotNullExpr(ast: o.AssertNotNull, ctx: EmitterVisitorContext): any { const result = super.visitAssertNotNullExpr(ast, ctx); ctx.print(ast, '!'); return result; @@ -162,7 +162,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): never { + override visitWrappedNodeExpr(ast: o.WrappedNodeExpr, ctx: EmitterVisitorContext): never { throw new Error('Cannot visit a WrappedNodeExpr when outputting Typescript.'); } @@ -175,7 +175,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor return null; } - visitInstantiateExpr(ast: o.InstantiateExpr, ctx: EmitterVisitorContext): any { + override visitInstantiateExpr(ast: o.InstantiateExpr, ctx: EmitterVisitorContext): any { ctx.print(ast, `new `); this.typeExpression++; ast.classExpr.visitExpression(this, ctx); diff --git a/packages/compiler/src/render3/view/t2_binder.ts b/packages/compiler/src/render3/view/t2_binder.ts index 5226823a53..ca4fca3268 100644 --- a/packages/compiler/src/render3/view/t2_binder.ts +++ b/packages/compiler/src/render3/view/t2_binder.ts @@ -51,7 +51,7 @@ export class R3TargetBinder implements TargetB // Finally, run the TemplateBinder to bind references, variables, and other entities within the // template. This extracts all the metadata that doesn't depend on directive matching. const {expressions, symbols, nestingLevel, usedPipes} = - TemplateBinder.apply(target.template, scope); + TemplateBinder.applyWithScope(target.template, scope); return new R3BoundTarget( target, directives, bindings, references, expressions, symbols, nestingLevel, templateEntities, usedPipes); @@ -347,7 +347,7 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor { // This method is defined to reconcile the type of TemplateBinder since both // RecursiveAstVisitor and Visitor define the visit() method in their // interfaces. - visit(node: AST|Node, context?: any) { + override visit(node: AST|Node, context?: any) { if (node instanceof AST) { node.visit(this, context); } else { @@ -367,7 +367,7 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor { * nesting level (how many levels deep within the template structure the `Template` is), starting * at 1. */ - static apply(template: Node[], scope: Scope): { + static applyWithScope(template: Node[], scope: Scope): { expressions: Map, symbols: Map, nestingLevel: Map, @@ -461,7 +461,7 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor { visitBoundText(text: BoundText) { text.value.visit(this); } - visitPipe(ast: BindingPipe, context: any): any { + override visitPipe(ast: BindingPipe, context: any): any { this.usedPipes.add(ast.name); return super.visitPipe(ast, context); } @@ -469,27 +469,27 @@ class TemplateBinder extends RecursiveAstVisitor implements Visitor { // These five types of AST expressions can refer to expression roots, which could be variables // or references in the current scope. - visitPropertyRead(ast: PropertyRead, context: any): any { + override visitPropertyRead(ast: PropertyRead, context: any): any { this.maybeMap(context, ast, ast.name); return super.visitPropertyRead(ast, context); } - visitSafePropertyRead(ast: SafePropertyRead, context: any): any { + override visitSafePropertyRead(ast: SafePropertyRead, context: any): any { this.maybeMap(context, ast, ast.name); return super.visitSafePropertyRead(ast, context); } - visitPropertyWrite(ast: PropertyWrite, context: any): any { + override visitPropertyWrite(ast: PropertyWrite, context: any): any { this.maybeMap(context, ast, ast.name); return super.visitPropertyWrite(ast, context); } - visitMethodCall(ast: MethodCall, context: any): any { + override visitMethodCall(ast: MethodCall, context: any): any { this.maybeMap(context, ast, ast.name); return super.visitMethodCall(ast, context); } - visitSafeMethodCall(ast: SafeMethodCall, context: any): any { + override visitSafeMethodCall(ast: SafeMethodCall, context: any): any { this.maybeMap(context, ast, ast.name); return super.visitSafeMethodCall(ast, context); } diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index 9f5d1b6191..600c955626 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -1495,7 +1495,7 @@ export class ValueConverter extends AstMemoryEfficientTransformer { } // AstMemoryEfficientTransformer - visitPipe(pipe: BindingPipe, context: any): AST { + override visitPipe(pipe: BindingPipe, context: any): AST { // Allocate a slot to create the pipe const slot = this.allocateSlot(); const slotPseudoLocal = `PIPE:${slot}`; @@ -1528,7 +1528,7 @@ export class ValueConverter extends AstMemoryEfficientTransformer { }); } - visitLiteralArray(array: LiteralArray, context: any): AST { + override visitLiteralArray(array: LiteralArray, context: any): AST { return new BuiltinFunctionCall( array.span, array.sourceSpan, this.visitAll(array.expressions), values => { // If the literal has calculated (non-literal) elements transform it into @@ -1539,7 +1539,7 @@ export class ValueConverter extends AstMemoryEfficientTransformer { }); } - visitLiteralMap(map: LiteralMap, context: any): AST { + override visitLiteralMap(map: LiteralMap, context: any): AST { return new BuiltinFunctionCall(map.span, map.sourceSpan, this.visitAll(map.values), values => { // If the literal has calculated (non-literal) elements transform it into // calls to literal factories that compose the literal and will cache intermediate diff --git a/packages/compiler/src/resource_loader.ts b/packages/compiler/src/resource_loader.ts index ec9d91af21..ea65396ef1 100644 --- a/packages/compiler/src/resource_loader.ts +++ b/packages/compiler/src/resource_loader.ts @@ -7,11 +7,12 @@ */ /** - * An interface for retrieving documents by URL that the compiler uses - * to load templates. + * An interface for retrieving documents by URL that the compiler uses to + * load templates. + * + * This is an abstract class, rather than an interface, so that it can be used + * as injection token. */ -export class ResourceLoader { - get(url: string): Promise|string { - return ''; - } +export abstract class ResourceLoader { + abstract get(url: string): Promise|string; } diff --git a/packages/compiler/src/template_parser/binding_parser.ts b/packages/compiler/src/template_parser/binding_parser.ts index daffb70155..8757e39d79 100644 --- a/packages/compiler/src/template_parser/binding_parser.ts +++ b/packages/compiler/src/template_parser/binding_parser.ts @@ -568,7 +568,7 @@ export class BindingParser { export class PipeCollector extends RecursiveAstVisitor { pipes = new Map(); - visitPipe(ast: BindingPipe, context: any): any { + override visitPipe(ast: BindingPipe, context: any): any { this.pipes.set(ast.name, ast); ast.exp.visit(this); this.visitAll(ast.args, context); diff --git a/packages/compiler/src/template_parser/template_ast.ts b/packages/compiler/src/template_parser/template_ast.ts index 4774890e61..323a70afa3 100644 --- a/packages/compiler/src/template_parser/template_ast.ts +++ b/packages/compiler/src/template_parser/template_ast.ts @@ -328,7 +328,7 @@ export class RecursiveTemplateAstVisitor extends NullTemplateVisitor implements } // Nodes with children - visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any { + override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any { return this.visitChildren(context, visit => { visit(ast.attrs); visit(ast.references); @@ -339,7 +339,7 @@ export class RecursiveTemplateAstVisitor extends NullTemplateVisitor implements }); } - visitElement(ast: ElementAst, context: any): any { + override visitElement(ast: ElementAst, context: any): any { return this.visitChildren(context, visit => { visit(ast.attrs); visit(ast.inputs); @@ -351,7 +351,7 @@ export class RecursiveTemplateAstVisitor extends NullTemplateVisitor implements }); } - visitDirective(ast: DirectiveAst, context: any): any { + override visitDirective(ast: DirectiveAst, context: any): any { return this.visitChildren(context, visit => { visit(ast.inputs); visit(ast.hostProperties); diff --git a/packages/compiler/test/directive_resolver_spec.ts b/packages/compiler/test/directive_resolver_spec.ts index a1d7d96f2f..e2fcabb557 100644 --- a/packages/compiler/test/directive_resolver_spec.ts +++ b/packages/compiler/test/directive_resolver_spec.ts @@ -227,7 +227,7 @@ class SomeDirectiveWithoutMetadata {} } class Child extends Parent { - @Input('p22') p2: any; + @Input('p22') override p2: any; @Input() p3: any; } @@ -282,7 +282,7 @@ class SomeDirectiveWithoutMetadata {} } class Child extends Parent { - @Output('p22') p2: any; + @Output('p22') override p2: any; @Output() p3: any; } @@ -328,7 +328,7 @@ class SomeDirectiveWithoutMetadata {} } class Child extends Parent { - @HostBinding('p22') p2: any; + @HostBinding('p22') override p2: any; @HostBinding() p3: any; } @@ -350,7 +350,7 @@ class SomeDirectiveWithoutMetadata {} class Child extends Parent { @HostListener('p22') - p2() { + override p2() { } @HostListener('p3') p3() { @@ -375,10 +375,10 @@ class SomeDirectiveWithoutMetadata {} class Child extends Parent { @HostListener('c1') - p1() { + override p1() { } - @HostBinding('c2') p2: any; + @HostBinding('c2') override p2: any; } const directiveMetadata = resolver.resolve(Child); @@ -426,7 +426,7 @@ class SomeDirectiveWithoutMetadata {} } class Child extends Parent { - @ContentChild('p22') p2: any; + @ContentChild('p22') override p2: any; @ContentChild('p3') p3: any; } diff --git a/packages/compiler/test/expression_parser/ast_spec.ts b/packages/compiler/test/expression_parser/ast_spec.ts index c49ff622f4..989d199e57 100644 --- a/packages/compiler/test/expression_parser/ast_spec.ts +++ b/packages/compiler/test/expression_parser/ast_spec.ts @@ -30,7 +30,7 @@ describe('RecursiveAstVisitor', () => { }); class Visitor extends RecursiveAstVisitor { - visit(node: AST, path: AST[]) { + override visit(node: AST, path: AST[]) { path.push(node); node.visit(this, path); } diff --git a/packages/compiler/test/expression_parser/utils/unparser.ts b/packages/compiler/test/expression_parser/utils/unparser.ts index ba541ed483..a3658d769c 100644 --- a/packages/compiler/test/expression_parser/utils/unparser.ts +++ b/packages/compiler/test/expression_parser/utils/unparser.ts @@ -231,7 +231,7 @@ export function unparseWithSpan( ]); } - visit(ast: AST, unparsedList: UnparsedWithSpan[]) { + override visit(ast: AST, unparsedList: UnparsedWithSpan[]) { this.recordUnparsed(ast, 'span', unparsedList); if (ast.hasOwnProperty('nameSpan')) { this.recordUnparsed(ast, 'nameSpan', unparsedList); diff --git a/packages/compiler/test/expression_parser/utils/validator.ts b/packages/compiler/test/expression_parser/utils/validator.ts index 81b330d68c..a24c8dbe55 100644 --- a/packages/compiler/test/expression_parser/utils/validator.ts +++ b/packages/compiler/test/expression_parser/utils/validator.ts @@ -13,7 +13,7 @@ import {unparse} from './unparser'; class ASTValidator extends RecursiveAstVisitor { private parentSpan: ParseSpan|undefined; - visit(ast: AST) { + override visit(ast: AST) { this.parentSpan = undefined; ast.visit(this); } @@ -34,87 +34,87 @@ class ASTValidator extends RecursiveAstVisitor { this.parentSpan = oldParent; } - visitUnary(ast: Unary, context: any): any { + override visitUnary(ast: Unary, context: any): any { this.validate(ast, () => super.visitUnary(ast, context)); } - visitBinary(ast: Binary, context: any): any { + override visitBinary(ast: Binary, context: any): any { this.validate(ast, () => super.visitBinary(ast, context)); } - visitChain(ast: Chain, context: any): any { + override visitChain(ast: Chain, context: any): any { this.validate(ast, () => super.visitChain(ast, context)); } - visitConditional(ast: Conditional, context: any): any { + override visitConditional(ast: Conditional, context: any): any { this.validate(ast, () => super.visitConditional(ast, context)); } - visitFunctionCall(ast: FunctionCall, context: any): any { + override visitFunctionCall(ast: FunctionCall, context: any): any { this.validate(ast, () => super.visitFunctionCall(ast, context)); } - visitImplicitReceiver(ast: ImplicitReceiver, context: any): any { + override visitImplicitReceiver(ast: ImplicitReceiver, context: any): any { this.validate(ast, () => super.visitImplicitReceiver(ast, context)); } - visitInterpolation(ast: Interpolation, context: any): any { + override visitInterpolation(ast: Interpolation, context: any): any { this.validate(ast, () => super.visitInterpolation(ast, context)); } - visitKeyedRead(ast: KeyedRead, context: any): any { + override visitKeyedRead(ast: KeyedRead, context: any): any { this.validate(ast, () => super.visitKeyedRead(ast, context)); } - visitKeyedWrite(ast: KeyedWrite, context: any): any { + override visitKeyedWrite(ast: KeyedWrite, context: any): any { this.validate(ast, () => super.visitKeyedWrite(ast, context)); } - visitLiteralArray(ast: LiteralArray, context: any): any { + override visitLiteralArray(ast: LiteralArray, context: any): any { this.validate(ast, () => super.visitLiteralArray(ast, context)); } - visitLiteralMap(ast: LiteralMap, context: any): any { + override visitLiteralMap(ast: LiteralMap, context: any): any { this.validate(ast, () => super.visitLiteralMap(ast, context)); } - visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any { + override visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any { this.validate(ast, () => super.visitLiteralPrimitive(ast, context)); } - visitMethodCall(ast: MethodCall, context: any): any { + override visitMethodCall(ast: MethodCall, context: any): any { this.validate(ast, () => super.visitMethodCall(ast, context)); } - visitPipe(ast: BindingPipe, context: any): any { + override visitPipe(ast: BindingPipe, context: any): any { this.validate(ast, () => super.visitPipe(ast, context)); } - visitPrefixNot(ast: PrefixNot, context: any): any { + override visitPrefixNot(ast: PrefixNot, context: any): any { this.validate(ast, () => super.visitPrefixNot(ast, context)); } - visitPropertyRead(ast: PropertyRead, context: any): any { + override visitPropertyRead(ast: PropertyRead, context: any): any { this.validate(ast, () => super.visitPropertyRead(ast, context)); } - visitPropertyWrite(ast: PropertyWrite, context: any): any { + override visitPropertyWrite(ast: PropertyWrite, context: any): any { this.validate(ast, () => super.visitPropertyWrite(ast, context)); } - visitQuote(ast: Quote, context: any): any { + override visitQuote(ast: Quote, context: any): any { this.validate(ast, () => super.visitQuote(ast, context)); } - visitSafeMethodCall(ast: SafeMethodCall, context: any): any { + override visitSafeMethodCall(ast: SafeMethodCall, context: any): any { this.validate(ast, () => super.visitSafeMethodCall(ast, context)); } - visitSafePropertyRead(ast: SafePropertyRead, context: any): any { + override visitSafePropertyRead(ast: SafePropertyRead, context: any): any { this.validate(ast, () => super.visitSafePropertyRead(ast, context)); } - visitSafeKeyedRead(ast: SafeKeyedRead, context: any): any { + override visitSafeKeyedRead(ast: SafeKeyedRead, context: any): any { this.validate(ast, () => super.visitSafeKeyedRead(ast, context)); } } diff --git a/packages/compiler/test/i18n/serializers/i18n_ast_spec.ts b/packages/compiler/test/i18n/serializers/i18n_ast_spec.ts index 7b2fe3b7b7..2030762403 100644 --- a/packages/compiler/test/i18n/serializers/i18n_ast_spec.ts +++ b/packages/compiler/test/i18n/serializers/i18n_ast_spec.ts @@ -58,15 +58,15 @@ class RecurseVisitor extends i18n.RecurseVisitor { phCount = 0; icuPhCount = 0; - visitText(text: i18n.Text, context?: any): any { + override visitText(text: i18n.Text, context?: any): any { this.textCount++; } - visitPlaceholder(ph: i18n.Placeholder, context?: any): any { + override visitPlaceholder(ph: i18n.Placeholder, context?: any): any { this.phCount++; } - visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any { + override visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any { this.icuPhCount++; } } diff --git a/packages/compiler/test/render3/util/expression.ts b/packages/compiler/test/render3/util/expression.ts index 0eb621d078..84092cd513 100644 --- a/packages/compiler/test/render3/util/expression.ts +++ b/packages/compiler/test/render3/util/expression.ts @@ -22,7 +22,7 @@ class ExpressionSourceHumanizer extends e.RecursiveAstVisitor implements t.Visit // This method is defined to reconcile the type of ExpressionSourceHumanizer // since both RecursiveAstVisitor and Visitor define the visit() method in // their interfaces. - visit(node: e.AST|t.Node, context?: any) { + override visit(node: e.AST|t.Node, context?: any) { if (node instanceof e.AST) { node.visit(this, context); } else { @@ -34,87 +34,87 @@ class ExpressionSourceHumanizer extends e.RecursiveAstVisitor implements t.Visit this.recordAst(ast); this.visitAll([ast.ast], null); } - visitBinary(ast: e.Binary) { + override visitBinary(ast: e.Binary) { this.recordAst(ast); super.visitBinary(ast, null); } - visitChain(ast: e.Chain) { + override visitChain(ast: e.Chain) { this.recordAst(ast); super.visitChain(ast, null); } - visitConditional(ast: e.Conditional) { + override visitConditional(ast: e.Conditional) { this.recordAst(ast); super.visitConditional(ast, null); } - visitFunctionCall(ast: e.FunctionCall) { + override visitFunctionCall(ast: e.FunctionCall) { this.recordAst(ast); super.visitFunctionCall(ast, null); } - visitImplicitReceiver(ast: e.ImplicitReceiver) { + override visitImplicitReceiver(ast: e.ImplicitReceiver) { this.recordAst(ast); super.visitImplicitReceiver(ast, null); } - visitInterpolation(ast: e.Interpolation) { + override visitInterpolation(ast: e.Interpolation) { this.recordAst(ast); super.visitInterpolation(ast, null); } - visitKeyedRead(ast: e.KeyedRead) { + override visitKeyedRead(ast: e.KeyedRead) { this.recordAst(ast); super.visitKeyedRead(ast, null); } - visitKeyedWrite(ast: e.KeyedWrite) { + override visitKeyedWrite(ast: e.KeyedWrite) { this.recordAst(ast); super.visitKeyedWrite(ast, null); } - visitLiteralPrimitive(ast: e.LiteralPrimitive) { + override visitLiteralPrimitive(ast: e.LiteralPrimitive) { this.recordAst(ast); super.visitLiteralPrimitive(ast, null); } - visitLiteralArray(ast: e.LiteralArray) { + override visitLiteralArray(ast: e.LiteralArray) { this.recordAst(ast); super.visitLiteralArray(ast, null); } - visitLiteralMap(ast: e.LiteralMap) { + override visitLiteralMap(ast: e.LiteralMap) { this.recordAst(ast); super.visitLiteralMap(ast, null); } - visitMethodCall(ast: e.MethodCall) { + override visitMethodCall(ast: e.MethodCall) { this.recordAst(ast); super.visitMethodCall(ast, null); } - visitNonNullAssert(ast: e.NonNullAssert) { + override visitNonNullAssert(ast: e.NonNullAssert) { this.recordAst(ast); super.visitNonNullAssert(ast, null); } - visitPipe(ast: e.BindingPipe) { + override visitPipe(ast: e.BindingPipe) { this.recordAst(ast); super.visitPipe(ast, null); } - visitPrefixNot(ast: e.PrefixNot) { + override visitPrefixNot(ast: e.PrefixNot) { this.recordAst(ast); super.visitPrefixNot(ast, null); } - visitPropertyRead(ast: e.PropertyRead) { + override visitPropertyRead(ast: e.PropertyRead) { this.recordAst(ast); super.visitPropertyRead(ast, null); } - visitPropertyWrite(ast: e.PropertyWrite) { + override visitPropertyWrite(ast: e.PropertyWrite) { this.recordAst(ast); super.visitPropertyWrite(ast, null); } - visitSafeMethodCall(ast: e.SafeMethodCall) { + override visitSafeMethodCall(ast: e.SafeMethodCall) { this.recordAst(ast); super.visitSafeMethodCall(ast, null); } - visitSafePropertyRead(ast: e.SafePropertyRead) { + override visitSafePropertyRead(ast: e.SafePropertyRead) { this.recordAst(ast); super.visitSafePropertyRead(ast, null); } - visitQuote(ast: e.Quote) { + override visitQuote(ast: e.Quote) { this.recordAst(ast); super.visitQuote(ast, null); } - visitSafeKeyedRead(ast: e.SafeKeyedRead) { + override visitSafeKeyedRead(ast: e.SafeKeyedRead) { this.recordAst(ast); super.visitSafeKeyedRead(ast, null); } diff --git a/packages/compiler/test/style_url_resolver_spec.ts b/packages/compiler/test/style_url_resolver_spec.ts index 35a88889df..a49eebc0a4 100644 --- a/packages/compiler/test/style_url_resolver_spec.ts +++ b/packages/compiler/test/style_url_resolver_spec.ts @@ -138,7 +138,7 @@ class FakeUrlResolver extends UrlResolver { super(); } - resolve(baseUrl: string, url: string): string { + override resolve(baseUrl: string, url: string): string { return 'fake_resolved_url'; } } diff --git a/packages/compiler/test/template_parser/template_parser_spec.ts b/packages/compiler/test/template_parser/template_parser_spec.ts index 1c7a9116dc..50581c1c1f 100644 --- a/packages/compiler/test/template_parser/template_parser_spec.ts +++ b/packages/compiler/test/template_parser/template_parser_spec.ts @@ -238,7 +238,7 @@ class ThrowingVisitor implements TemplateAstVisitor { } class FooAstTransformer extends ThrowingVisitor { - visitElement(ast: ElementAst, context: any): any { + override visitElement(ast: ElementAst, context: any): any { if (ast.name != 'div') return ast; return new ElementAst( 'foo', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan, @@ -247,7 +247,7 @@ class FooAstTransformer extends ThrowingVisitor { } class BarAstTransformer extends FooAstTransformer { - visitElement(ast: ElementAst, context: any): any { + override visitElement(ast: ElementAst, context: any): any { if (ast.name != 'foo') return ast; return new ElementAst( 'bar', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan, @@ -340,7 +340,7 @@ describe('TemplateAstVisitor', () => { it('should visit NgContentAst', () => { expectVisitedNode(new class extends NullVisitor { - visitNgContent(ast: NgContentAst, context: any): any { + override visitNgContent(ast: NgContentAst, context: any): any { return ast; } }, new NgContentAst(0, 0, null!)); @@ -348,7 +348,7 @@ describe('TemplateAstVisitor', () => { it('should visit EmbeddedTemplateAst', () => { expectVisitedNode(new class extends NullVisitor { - visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any) { + override visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any) { return ast; } }, new EmbeddedTemplateAst([], [], [], [], [], [], false, [], [], 0, null!)); @@ -356,7 +356,7 @@ describe('TemplateAstVisitor', () => { it('should visit ElementAst', () => { expectVisitedNode(new class extends NullVisitor { - visitElement(ast: ElementAst, context: any) { + override visitElement(ast: ElementAst, context: any) { return ast; } }, new ElementAst('foo', [], [], [], [], [], [], false, [], [], 0, null!, null!)); @@ -364,7 +364,7 @@ describe('TemplateAstVisitor', () => { it('should visit RefererenceAst', () => { expectVisitedNode(new class extends NullVisitor { - visitReference(ast: ReferenceAst, context: any): any { + override visitReference(ast: ReferenceAst, context: any): any { return ast; } }, new ReferenceAst('foo', null!, null!, null!)); @@ -372,7 +372,7 @@ describe('TemplateAstVisitor', () => { it('should visit VariableAst', () => { expectVisitedNode(new class extends NullVisitor { - visitVariable(ast: VariableAst, context: any): any { + override visitVariable(ast: VariableAst, context: any): any { return ast; } }, new VariableAst('foo', 'bar', null!)); @@ -380,7 +380,7 @@ describe('TemplateAstVisitor', () => { it('should visit BoundEventAst', () => { expectVisitedNode(new class extends NullVisitor { - visitEvent(ast: BoundEventAst, context: any): any { + override visitEvent(ast: BoundEventAst, context: any): any { return ast; } }, new BoundEventAst('foo', 'bar', 'goo', null!, null!, null!)); @@ -388,7 +388,7 @@ describe('TemplateAstVisitor', () => { it('should visit BoundElementPropertyAst', () => { expectVisitedNode(new class extends NullVisitor { - visitElementProperty(ast: BoundElementPropertyAst, context: any): any { + override visitElementProperty(ast: BoundElementPropertyAst, context: any): any { return ast; } }, new BoundElementPropertyAst('foo', null!, null!, null!, 'bar', null!)); @@ -396,7 +396,7 @@ describe('TemplateAstVisitor', () => { it('should visit AttrAst', () => { expectVisitedNode(new class extends NullVisitor { - visitAttr(ast: AttrAst, context: any): any { + override visitAttr(ast: AttrAst, context: any): any { return ast; } }, new AttrAst('foo', 'bar', null!)); @@ -404,7 +404,7 @@ describe('TemplateAstVisitor', () => { it('should visit BoundTextAst', () => { expectVisitedNode(new class extends NullVisitor { - visitBoundText(ast: BoundTextAst, context: any): any { + override visitBoundText(ast: BoundTextAst, context: any): any { return ast; } }, new BoundTextAst(null!, 0, null!)); @@ -412,7 +412,7 @@ describe('TemplateAstVisitor', () => { it('should visit TextAst', () => { expectVisitedNode(new class extends NullVisitor { - visitText(ast: TextAst, context: any): any { + override visitText(ast: TextAst, context: any): any { return ast; } }, new TextAst('foo', 0, null!)); @@ -420,7 +420,7 @@ describe('TemplateAstVisitor', () => { it('should visit DirectiveAst', () => { expectVisitedNode(new class extends NullVisitor { - visitDirective(ast: DirectiveAst, context: any): any { + override visitDirective(ast: DirectiveAst, context: any): any { return ast; } }, new DirectiveAst(null!, [], [], [], 0, null!)); @@ -428,7 +428,7 @@ describe('TemplateAstVisitor', () => { it('should visit DirectiveAst', () => { expectVisitedNode(new class extends NullVisitor { - visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any { + override visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any { return ast; } }, new BoundDirectivePropertyAst('foo', 'bar', null!, null!)); diff --git a/packages/compiler/test/template_parser/util/expression.ts b/packages/compiler/test/template_parser/util/expression.ts index 54434e56d8..5ee6186fca 100644 --- a/packages/compiler/test/template_parser/util/expression.ts +++ b/packages/compiler/test/template_parser/util/expression.ts @@ -22,7 +22,7 @@ class ExpressionSourceHumanizer extends e.RecursiveAstVisitor implements t.Templ // This method is defined to reconcile the type of ExpressionSourceHumanizer // since both RecursiveAstVisitor and TemplateAstVisitor define the visit() // method in their interfaces. - visit(node: e.AST|t.TemplateAst, context?: any) { + override visit(node: e.AST|t.TemplateAst, context?: any) { node.visit(this, context); } @@ -30,91 +30,91 @@ class ExpressionSourceHumanizer extends e.RecursiveAstVisitor implements t.Templ this.recordAst(ast); this.visitAll([ast.ast], null); } - visitUnary(ast: e.Unary) { + override visitUnary(ast: e.Unary) { this.recordAst(ast); super.visitUnary(ast, null); } - visitBinary(ast: e.Binary) { + override visitBinary(ast: e.Binary) { this.recordAst(ast); super.visitBinary(ast, null); } - visitChain(ast: e.Chain) { + override visitChain(ast: e.Chain) { this.recordAst(ast); super.visitChain(ast, null); } - visitConditional(ast: e.Conditional) { + override visitConditional(ast: e.Conditional) { this.recordAst(ast); super.visitConditional(ast, null); } - visitFunctionCall(ast: e.FunctionCall) { + override visitFunctionCall(ast: e.FunctionCall) { this.recordAst(ast); super.visitFunctionCall(ast, null); } - visitImplicitReceiver(ast: e.ImplicitReceiver) { + override visitImplicitReceiver(ast: e.ImplicitReceiver) { this.recordAst(ast); super.visitImplicitReceiver(ast, null); } - visitInterpolation(ast: e.Interpolation) { + override visitInterpolation(ast: e.Interpolation) { this.recordAst(ast); super.visitInterpolation(ast, null); } - visitKeyedRead(ast: e.KeyedRead) { + override visitKeyedRead(ast: e.KeyedRead) { this.recordAst(ast); super.visitKeyedRead(ast, null); } - visitKeyedWrite(ast: e.KeyedWrite) { + override visitKeyedWrite(ast: e.KeyedWrite) { this.recordAst(ast); super.visitKeyedWrite(ast, null); } - visitLiteralPrimitive(ast: e.LiteralPrimitive) { + override visitLiteralPrimitive(ast: e.LiteralPrimitive) { this.recordAst(ast); super.visitLiteralPrimitive(ast, null); } - visitLiteralArray(ast: e.LiteralArray) { + override visitLiteralArray(ast: e.LiteralArray) { this.recordAst(ast); super.visitLiteralArray(ast, null); } - visitLiteralMap(ast: e.LiteralMap) { + override visitLiteralMap(ast: e.LiteralMap) { this.recordAst(ast); super.visitLiteralMap(ast, null); } - visitMethodCall(ast: e.MethodCall) { + override visitMethodCall(ast: e.MethodCall) { this.recordAst(ast); super.visitMethodCall(ast, null); } - visitNonNullAssert(ast: e.NonNullAssert) { + override visitNonNullAssert(ast: e.NonNullAssert) { this.recordAst(ast); super.visitNonNullAssert(ast, null); } - visitPipe(ast: e.BindingPipe) { + override visitPipe(ast: e.BindingPipe) { this.recordAst(ast); super.visitPipe(ast, null); } - visitPrefixNot(ast: e.PrefixNot) { + override visitPrefixNot(ast: e.PrefixNot) { this.recordAst(ast); super.visitPrefixNot(ast, null); } - visitPropertyRead(ast: e.PropertyRead) { + override visitPropertyRead(ast: e.PropertyRead) { this.recordAst(ast); super.visitPropertyRead(ast, null); } - visitPropertyWrite(ast: e.PropertyWrite) { + override visitPropertyWrite(ast: e.PropertyWrite) { this.recordAst(ast); super.visitPropertyWrite(ast, null); } - visitSafeMethodCall(ast: e.SafeMethodCall) { + override visitSafeMethodCall(ast: e.SafeMethodCall) { this.recordAst(ast); super.visitSafeMethodCall(ast, null); } - visitSafePropertyRead(ast: e.SafePropertyRead) { + override visitSafePropertyRead(ast: e.SafePropertyRead) { this.recordAst(ast); super.visitSafePropertyRead(ast, null); } - visitQuote(ast: e.Quote) { + override visitQuote(ast: e.Quote) { this.recordAst(ast); super.visitQuote(ast, null); } - visitSafeKeyedRead(ast: e.SafeKeyedRead) { + override visitSafeKeyedRead(ast: e.SafeKeyedRead) { this.recordAst(ast); super.visitSafeKeyedRead(ast, null); } diff --git a/packages/compiler/testing/src/directive_resolver_mock.ts b/packages/compiler/testing/src/directive_resolver_mock.ts index e1d47be378..4a29a11436 100644 --- a/packages/compiler/testing/src/directive_resolver_mock.ts +++ b/packages/compiler/testing/src/directive_resolver_mock.ts @@ -18,10 +18,10 @@ export class MockDirectiveResolver extends DirectiveResolver { super(reflector); } - resolve(type: core.Type): core.Directive; - resolve(type: core.Type, throwIfNotFound: true): core.Directive; - resolve(type: core.Type, throwIfNotFound: boolean): core.Directive|null; - resolve(type: core.Type, throwIfNotFound = true): core.Directive|null { + override resolve(type: core.Type): core.Directive; + override resolve(type: core.Type, throwIfNotFound: true): core.Directive; + override resolve(type: core.Type, throwIfNotFound: boolean): core.Directive|null; + override resolve(type: core.Type, throwIfNotFound = true): core.Directive|null { return this._directives.get(type) || super.resolve(type, throwIfNotFound); } diff --git a/packages/compiler/testing/src/ng_module_resolver_mock.ts b/packages/compiler/testing/src/ng_module_resolver_mock.ts index cc69bf51df..83ff2fda84 100644 --- a/packages/compiler/testing/src/ng_module_resolver_mock.ts +++ b/packages/compiler/testing/src/ng_module_resolver_mock.ts @@ -28,7 +28,7 @@ export class MockNgModuleResolver extends NgModuleResolver { * default * `NgModuleResolver`, see `setNgModule`. */ - resolve(type: core.Type, throwIfNotFound = true): core.NgModule { + override resolve(type: core.Type, throwIfNotFound = true): core.NgModule { return this._ngModules.get(type) || super.resolve(type, throwIfNotFound)!; } } diff --git a/packages/compiler/testing/src/pipe_resolver_mock.ts b/packages/compiler/testing/src/pipe_resolver_mock.ts index 1fa6ece9a4..e64460230a 100644 --- a/packages/compiler/testing/src/pipe_resolver_mock.ts +++ b/packages/compiler/testing/src/pipe_resolver_mock.ts @@ -28,7 +28,7 @@ export class MockPipeResolver extends PipeResolver { * default * `PipeResolver`, see `setPipe`. */ - resolve(type: core.Type, throwIfNotFound = true): core.Pipe { + override resolve(type: core.Type, throwIfNotFound = true): core.Pipe { let metadata = this._pipes.get(type); if (!metadata) { metadata = super.resolve(type, throwIfNotFound)!;