refactor(compiler-cli): ensure compatibility with noImplicitOverride (#42512)

Adds the `override` keyword to the `compiler-cli` sources to ensure
compatibility with `noImplicitOverride`.

PR Close #42512
This commit is contained in:
Paul Gschwendtner 2021-06-07 17:25:45 +02:00 committed by Andrew Kushnir
parent 96c93260a2
commit ccbb913f4b
31 changed files with 117 additions and 110 deletions

View File

@ -30,7 +30,7 @@ export class IifeEmitScope<TStatement, TExpression> extends EmitScope<TStatement
* Wraps the output from `EmitScope.translateDefinition()` and `EmitScope.getConstantStatements()` * Wraps the output from `EmitScope.translateDefinition()` and `EmitScope.getConstantStatements()`
* in an IIFE. * in an IIFE.
*/ */
translateDefinition(definition: o.Expression): TExpression { override translateDefinition(definition: o.Expression): TExpression {
const constantStatements = super.getConstantStatements(); const constantStatements = super.getConstantStatements();
const returnStatement = const returnStatement =
@ -44,7 +44,7 @@ export class IifeEmitScope<TStatement, TExpression> extends EmitScope<TStatement
* It is not valid to call this method, since there will be no shared constant statements - they * It is not valid to call this method, since there will be no shared constant statements - they
* are already emitted in the IIFE alongside the translated definition. * are already emitted in the IIFE alongside the translated definition.
*/ */
getConstantStatements(): TStatement[] { override getConstantStatements(): TStatement[] {
throw new Error('BUG - IifeEmitScope should not expose any constant statements'); throw new Error('BUG - IifeEmitScope should not expose any constant statements');
} }
} }

View File

@ -23,7 +23,7 @@ export class DtsDependencyHost extends EsmDependencyHost {
/** /**
* Attempts to process the `importPath` directly and also inside `@types/...`. * Attempts to process the `importPath` directly and also inside `@types/...`.
*/ */
protected processImport( protected override processImport(
importPath: string, file: AbsoluteFsPath, dependencies: Set<AbsoluteFsPath>, importPath: string, file: AbsoluteFsPath, dependencies: Set<AbsoluteFsPath>,
missing: Set<string>, deepImports: Set<string>, alreadySeen: Set<AbsoluteFsPath>): boolean { missing: Set<string>, deepImports: Set<string>, alreadySeen: Set<AbsoluteFsPath>): boolean {
return super.processImport(importPath, file, dependencies, missing, deepImports, alreadySeen) || return super.processImport(importPath, file, dependencies, missing, deepImports, alreadySeen) ||

View File

@ -35,7 +35,7 @@ export class TargetedEntryPointFinder extends TracingEntryPointFinder {
* Search for Angular entry-points that can be reached from the entry-point specified by the given * Search for Angular entry-points that can be reached from the entry-point specified by the given
* `targetPath`. * `targetPath`.
*/ */
findEntryPoints(): SortedEntryPointsInfo { override findEntryPoints(): SortedEntryPointsInfo {
const entryPoints = super.findEntryPoints(); const entryPoints = super.findEntryPoints();
const invalidTarget = const invalidTarget =

View File

@ -41,7 +41,7 @@ export class ParallelTaskQueue extends BaseTaskQueue {
return nextTask; return nextTask;
} }
markAsCompleted(task: Task): void { override markAsCompleted(task: Task): void {
super.markAsCompleted(task); super.markAsCompleted(task);
if (!this.dependencies.has(task)) { if (!this.dependencies.has(task)) {
@ -62,7 +62,7 @@ export class ParallelTaskQueue extends BaseTaskQueue {
} }
} }
toString(): string { override toString(): string {
return `${super.toString()}\n` + return `${super.toString()}\n` +
` Blocked tasks (${this.blockedTasks.size}): ${this.stringifyBlockedTasks(' ')}`; ` Blocked tasks (${this.blockedTasks.size}): ${this.stringifyBlockedTasks(' ')}`;
} }

View File

@ -35,7 +35,7 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
this.compilerHost = src.host; this.compilerHost = src.host;
} }
getImportOfIdentifier(id: ts.Identifier): Import|null { override getImportOfIdentifier(id: ts.Identifier): Import|null {
const requireCall = this.findCommonJsImport(id); const requireCall = this.findCommonJsImport(id);
if (requireCall === null) { if (requireCall === null) {
return null; return null;
@ -43,11 +43,11 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
return {from: requireCall.arguments[0].text, name: id.text}; return {from: requireCall.arguments[0].text, name: id.text};
} }
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
return this.getCommonJsModuleDeclaration(id) || super.getDeclarationOfIdentifier(id); return this.getCommonJsModuleDeclaration(id) || super.getDeclarationOfIdentifier(id);
} }
getExportsOfModule(module: ts.Node): Map<string, Declaration>|null { override getExportsOfModule(module: ts.Node): Map<string, Declaration>|null {
return super.getExportsOfModule(module) || this.commonJsExports.get(module.getSourceFile()); return super.getExportsOfModule(module) || this.commonJsExports.get(module.getSourceFile());
} }
@ -64,7 +64,7 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
* in. * in.
* @returns an array of nodes of calls to the helper with the given name. * @returns an array of nodes of calls to the helper with the given name.
*/ */
protected getHelperCallsForClass(classSymbol: NgccClassSymbol, helperNames: string[]): protected override getHelperCallsForClass(classSymbol: NgccClassSymbol, helperNames: string[]):
ts.CallExpression[] { ts.CallExpression[] {
const esm5HelperCalls = super.getHelperCallsForClass(classSymbol, helperNames); const esm5HelperCalls = super.getHelperCallsForClass(classSymbol, helperNames);
if (esm5HelperCalls.length > 0) { if (esm5HelperCalls.length > 0) {
@ -221,7 +221,7 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
* If this is an IFE then try to grab the outer and inner classes otherwise fallback on the super * If this is an IFE then try to grab the outer and inner classes otherwise fallback on the super
* class. * class.
*/ */
protected getDeclarationOfExpression(expression: ts.Expression): Declaration|null { protected override getDeclarationOfExpression(expression: ts.Expression): Declaration|null {
const inner = getInnerClassDeclaration(expression); const inner = getInnerClassDeclaration(expression);
if (inner !== null) { if (inner !== null) {
const outer = getOuterNodeFromInnerDeclaration(inner); const outer = getOuterNodeFromInnerDeclaration(inner);

View File

@ -151,7 +151,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* `null` if either no decorators were present or if the declaration is not of a decoratable * `null` if either no decorators were present or if the declaration is not of a decoratable
* type. * type.
*/ */
getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[]|null { override getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[]|null {
const symbol = this.getClassSymbol(declaration); const symbol = this.getClassSymbol(declaration);
if (!symbol) { if (!symbol) {
return null; return null;
@ -169,7 +169,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* *
* @throws if `declaration` does not resolve to a class declaration. * @throws if `declaration` does not resolve to a class declaration.
*/ */
getMembersOfClass(clazz: ClassDeclaration): ClassMember[] { override getMembersOfClass(clazz: ClassDeclaration): ClassMember[] {
const classSymbol = this.getClassSymbol(clazz); const classSymbol = this.getClassSymbol(clazz);
if (!classSymbol) { if (!classSymbol) {
throw new Error(`Attempted to get members of a non-class: "${clazz.getText()}"`); throw new Error(`Attempted to get members of a non-class: "${clazz.getText()}"`);
@ -192,7 +192,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* *
* @throws if `declaration` does not resolve to a class declaration. * @throws if `declaration` does not resolve to a class declaration.
*/ */
getConstructorParameters(clazz: ClassDeclaration): CtorParameter[]|null { override getConstructorParameters(clazz: ClassDeclaration): CtorParameter[]|null {
const classSymbol = this.getClassSymbol(clazz); const classSymbol = this.getClassSymbol(clazz);
if (!classSymbol) { if (!classSymbol) {
throw new Error( throw new Error(
@ -205,7 +205,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
return null; return null;
} }
getBaseClassExpression(clazz: ClassDeclaration): ts.Expression|null { override getBaseClassExpression(clazz: ClassDeclaration): ts.Expression|null {
// First try getting the base class from an ES2015 class declaration // First try getting the base class from an ES2015 class declaration
const superBaseClassIdentifier = super.getBaseClassExpression(clazz); const superBaseClassIdentifier = super.getBaseClassExpression(clazz);
if (superBaseClassIdentifier) { if (superBaseClassIdentifier) {
@ -221,7 +221,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
return super.getBaseClassExpression(classSymbol.implementation.valueDeclaration); return super.getBaseClassExpression(classSymbol.implementation.valueDeclaration);
} }
getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier { override getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier {
const classSymbol = this.getClassSymbol(clazz); const classSymbol = this.getClassSymbol(clazz);
if (classSymbol === undefined) { if (classSymbol === undefined) {
throw new Error(`getInternalNameOfClass() called on a non-class: expected ${ throw new Error(`getInternalNameOfClass() called on a non-class: expected ${
@ -231,7 +231,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
classSymbol, classSymbol.implementation.valueDeclaration); classSymbol, classSymbol.implementation.valueDeclaration);
} }
getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier { override getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier {
const classSymbol = this.getClassSymbol(clazz); const classSymbol = this.getClassSymbol(clazz);
if (classSymbol === undefined) { if (classSymbol === undefined) {
throw new Error(`getAdjacentNameOfClass() called on a non-class: expected ${ throw new Error(`getAdjacentNameOfClass() called on a non-class: expected ${
@ -259,7 +259,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
/** /**
* Check whether the given node actually represents a class. * Check whether the given node actually represents a class.
*/ */
isClass(node: ts.Node): node is ClassDeclaration { override isClass(node: ts.Node): node is ClassDeclaration {
return super.isClass(node) || this.getClassSymbol(node) !== undefined; return super.isClass(node) || this.getClassSymbol(node) !== undefined;
} }
@ -279,7 +279,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* @returns metadata about the `Declaration` if the original declaration is found, or `null` * @returns metadata about the `Declaration` if the original declaration is found, or `null`
* otherwise. * otherwise.
*/ */
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
const superDeclaration = super.getDeclarationOfIdentifier(id); const superDeclaration = super.getDeclarationOfIdentifier(id);
// If no declaration was found, return. // If no declaration was found, return.
@ -355,7 +355,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
[]; [];
} }
getVariableValue(declaration: ts.VariableDeclaration): ts.Expression|null { override getVariableValue(declaration: ts.VariableDeclaration): ts.Expression|null {
const value = super.getVariableValue(declaration); const value = super.getVariableValue(declaration);
if (value) { if (value) {
return value; return value;
@ -434,7 +434,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* @returns the number of type parameters of the class, if known, or `null` if the declaration * @returns the number of type parameters of the class, if known, or `null` if the declaration
* is not a class or has an unknown number of type parameters. * is not a class or has an unknown number of type parameters.
*/ */
getGenericArityOfClass(clazz: ClassDeclaration): number|null { override getGenericArityOfClass(clazz: ClassDeclaration): number|null {
const dtsDeclaration = this.getDtsDeclaration(clazz); const dtsDeclaration = this.getDtsDeclaration(clazz);
if (dtsDeclaration && ts.isClassDeclaration(dtsDeclaration)) { if (dtsDeclaration && ts.isClassDeclaration(dtsDeclaration)) {
return dtsDeclaration.typeParameters ? dtsDeclaration.typeParameters.length : 0; return dtsDeclaration.typeParameters ? dtsDeclaration.typeParameters.length : 0;
@ -454,7 +454,7 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* Note that the `ts.ClassDeclaration` returned from this function may not be from the same * Note that the `ts.ClassDeclaration` returned from this function may not be from the same
* `ts.Program` as the input declaration. * `ts.Program` as the input declaration.
*/ */
getDtsDeclaration(declaration: DeclarationNode): ts.Declaration|null { override getDtsDeclaration(declaration: DeclarationNode): ts.Declaration|null {
if (this.dts === null) { if (this.dts === null) {
return null; return null;
} }
@ -769,8 +769,8 @@ export class Esm2015ReflectionHost extends TypeScriptReflectionHost implements N
* Resolve a `ts.Symbol` to its declaration and detect whether it corresponds with a known * Resolve a `ts.Symbol` to its declaration and detect whether it corresponds with a known
* declaration. * declaration.
*/ */
protected getDeclarationOfSymbol(symbol: ts.Symbol, originalId: ts.Identifier|null): Declaration protected override getDeclarationOfSymbol(symbol: ts.Symbol, originalId: ts.Identifier|null):
|null { Declaration|null {
const declaration = super.getDeclarationOfSymbol(symbol, originalId); const declaration = super.getDeclarationOfSymbol(symbol, originalId);
if (declaration === null) { if (declaration === null) {
return null; return null;

View File

@ -34,7 +34,7 @@ import {NgccClassSymbol} from './ngcc_host';
* *
*/ */
export class Esm5ReflectionHost extends Esm2015ReflectionHost { export class Esm5ReflectionHost extends Esm2015ReflectionHost {
getBaseClassExpression(clazz: ClassDeclaration): ts.Expression|null { override getBaseClassExpression(clazz: ClassDeclaration): ts.Expression|null {
const superBaseClassExpression = super.getBaseClassExpression(clazz); const superBaseClassExpression = super.getBaseClassExpression(clazz);
if (superBaseClassExpression !== null) { if (superBaseClassExpression !== null) {
return superBaseClassExpression; return superBaseClassExpression;
@ -71,7 +71,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @returns metadata about the `Declaration` if the original declaration is found, or `null` * @returns metadata about the `Declaration` if the original declaration is found, or `null`
* otherwise. * otherwise.
*/ */
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
const declaration = super.getDeclarationOfIdentifier(id); const declaration = super.getDeclarationOfIdentifier(id);
if (declaration === null) { if (declaration === null) {
@ -127,7 +127,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @param node the function declaration to parse. * @param node the function declaration to parse.
* @returns an object containing the node, statements and parameters of the function. * @returns an object containing the node, statements and parameters of the function.
*/ */
getDefinitionOfFunction(node: ts.Node): FunctionDefinition|null { override getDefinitionOfFunction(node: ts.Node): FunctionDefinition|null {
const definition = super.getDefinitionOfFunction(node); const definition = super.getDefinitionOfFunction(node);
if (definition === null) { if (definition === null) {
return null; return null;
@ -155,7 +155,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @param decl The `Declaration` to check. * @param decl The `Declaration` to check.
* @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`). * @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`).
*/ */
detectKnownDeclaration<T extends Declaration>(decl: T): T { override detectKnownDeclaration<T extends Declaration>(decl: T): T {
decl = super.detectKnownDeclaration(decl); decl = super.detectKnownDeclaration(decl);
// Also check for TS helpers // Also check for TS helpers
@ -180,7 +180,8 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @param declaration the declaration whose symbol we are finding. * @param declaration the declaration whose symbol we are finding.
* @returns the symbol for the node or `undefined` if it is not a "class" or has no symbol. * @returns the symbol for the node or `undefined` if it is not a "class" or has no symbol.
*/ */
protected getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol|undefined { protected override getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol
|undefined {
const classSymbol = super.getClassSymbolFromInnerDeclaration(declaration); const classSymbol = super.getClassSymbolFromInnerDeclaration(declaration);
if (classSymbol !== undefined) { if (classSymbol !== undefined) {
return classSymbol; return classSymbol;
@ -210,7 +211,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @returns an array of `ts.ParameterDeclaration` objects representing each of the parameters in * @returns an array of `ts.ParameterDeclaration` objects representing each of the parameters in
* the class's constructor or `null` if there is no constructor. * the class's constructor or `null` if there is no constructor.
*/ */
protected getConstructorParameterDeclarations(classSymbol: NgccClassSymbol): protected override getConstructorParameterDeclarations(classSymbol: NgccClassSymbol):
ts.ParameterDeclaration[]|null { ts.ParameterDeclaration[]|null {
const constructor = classSymbol.implementation.valueDeclaration; const constructor = classSymbol.implementation.valueDeclaration;
if (!ts.isFunctionDeclaration(constructor)) return null; if (!ts.isFunctionDeclaration(constructor)) return null;
@ -248,7 +249,8 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @param paramDecoratorsProperty the property that holds the parameter info we want to get. * @param paramDecoratorsProperty the property that holds the parameter info we want to get.
* @returns an array of objects containing the type and decorators for each parameter. * @returns an array of objects containing the type and decorators for each parameter.
*/ */
protected getParamInfoFromStaticProperty(paramDecoratorsProperty: ts.Symbol): ParamInfo[]|null { protected override getParamInfoFromStaticProperty(paramDecoratorsProperty: ts.Symbol):
ParamInfo[]|null {
const paramDecorators = getPropertyValueFromSymbol(paramDecoratorsProperty); const paramDecorators = getPropertyValueFromSymbol(paramDecoratorsProperty);
// The decorators array may be wrapped in a function. If so unwrap it. // The decorators array may be wrapped in a function. If so unwrap it.
const returnStatement = getReturnStatement(paramDecorators); const returnStatement = getReturnStatement(paramDecorators);
@ -284,8 +286,8 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* @param isStatic true if this member is static, false if it is an instance property. * @param isStatic true if this member is static, false if it is an instance property.
* @returns the reflected member information, or null if the symbol is not a member. * @returns the reflected member information, or null if the symbol is not a member.
*/ */
protected reflectMembers(symbol: ts.Symbol, decorators?: Decorator[], isStatic?: boolean): protected override reflectMembers(
ClassMember[]|null { symbol: ts.Symbol, decorators?: Decorator[], isStatic?: boolean): ClassMember[]|null {
const node = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; const node = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
const propertyDefinition = node && getPropertyDefinition(node); const propertyDefinition = node && getPropertyDefinition(node);
if (propertyDefinition) { if (propertyDefinition) {
@ -348,7 +350,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
* to reference the inner identifier inside the IIFE. * to reference the inner identifier inside the IIFE.
* @returns an array of statements that may contain helper calls. * @returns an array of statements that may contain helper calls.
*/ */
protected getStatementsForClass(classSymbol: NgccClassSymbol): ts.Statement[] { protected override getStatementsForClass(classSymbol: NgccClassSymbol): ts.Statement[] {
const classDeclarationParent = classSymbol.implementation.valueDeclaration.parent; const classDeclarationParent = classSymbol.implementation.valueDeclaration.parent;
return ts.isBlock(classDeclarationParent) ? Array.from(classDeclarationParent.statements) : []; return ts.isBlock(classDeclarationParent) ? Array.from(classDeclarationParent.statements) : [];
} }

View File

@ -36,7 +36,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
this.compilerHost = src.host; this.compilerHost = src.host;
} }
getImportOfIdentifier(id: ts.Identifier): Import|null { override getImportOfIdentifier(id: ts.Identifier): Import|null {
// Is `id` a namespaced property access, e.g. `Directive` in `core.Directive`? // Is `id` a namespaced property access, e.g. `Directive` in `core.Directive`?
// If so capture the symbol of the namespace, e.g. `core`. // If so capture the symbol of the namespace, e.g. `core`.
const nsIdentifier = findNamespaceOfIdentifier(id); const nsIdentifier = findNamespaceOfIdentifier(id);
@ -45,7 +45,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
return from !== null ? {from, name: id.text} : null; return from !== null ? {from, name: id.text} : null;
} }
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
// First we try one of the following: // First we try one of the following:
// 1. The `exports` identifier - referring to the current file/module. // 1. The `exports` identifier - referring to the current file/module.
// 2. An identifier (e.g. `foo`) that refers to an imported UMD module. // 2. An identifier (e.g. `foo`) that refers to an imported UMD module.
@ -83,7 +83,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
}; };
} }
getExportsOfModule(module: ts.Node): Map<string, Declaration>|null { override getExportsOfModule(module: ts.Node): Map<string, Declaration>|null {
return super.getExportsOfModule(module) || this.umdExports.get(module.getSourceFile()); return super.getExportsOfModule(module) || this.umdExports.get(module.getSourceFile());
} }
@ -107,12 +107,13 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
* @param sourceFile The module whose statements we want. * @param sourceFile The module whose statements we want.
* @returns An array of top level statements for the given module. * @returns An array of top level statements for the given module.
*/ */
protected getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[] { protected override getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[] {
const umdModule = this.getUmdModule(sourceFile); const umdModule = this.getUmdModule(sourceFile);
return umdModule !== null ? Array.from(umdModule.factoryFn.body.statements) : []; return umdModule !== null ? Array.from(umdModule.factoryFn.body.statements) : [];
} }
protected getClassSymbolFromOuterDeclaration(declaration: ts.Node): NgccClassSymbol|undefined { protected override getClassSymbolFromOuterDeclaration(declaration: ts.Node): NgccClassSymbol
|undefined {
const superSymbol = super.getClassSymbolFromOuterDeclaration(declaration); const superSymbol = super.getClassSymbolFromOuterDeclaration(declaration);
if (superSymbol) { if (superSymbol) {
return superSymbol; return superSymbol;
@ -143,7 +144,8 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
} }
protected getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol|undefined { protected override getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol
|undefined {
const superClassSymbol = super.getClassSymbolFromInnerDeclaration(declaration); const superClassSymbol = super.getClassSymbolFromInnerDeclaration(declaration);
if (superClassSymbol !== undefined) { if (superClassSymbol !== undefined) {
return superClassSymbol; return superClassSymbol;
@ -164,7 +166,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
/** /**
* Extract all "classes" from the `statement` and add them to the `classes` map. * Extract all "classes" from the `statement` and add them to the `classes` map.
*/ */
protected addClassSymbolsFromStatement( protected override addClassSymbolsFromStatement(
classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void { classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void {
super.addClassSymbolsFromStatement(classes, statement); super.addClassSymbolsFromStatement(classes, statement);
@ -184,7 +186,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
* *
* @param statement The statement that needs to be preprocessed. * @param statement The statement that needs to be preprocessed.
*/ */
protected preprocessStatement(statement: ts.Statement): void { protected override preprocessStatement(statement: ts.Statement): void {
super.preprocessStatement(statement); super.preprocessStatement(statement);
if (!isExportsStatement(statement)) { if (!isExportsStatement(statement)) {
@ -474,7 +476,7 @@ export class UmdReflectionHost extends Esm5ReflectionHost {
* If this is an IIFE then try to grab the outer and inner classes otherwise fallback on the super * If this is an IIFE then try to grab the outer and inner classes otherwise fallback on the super
* class. * class.
*/ */
protected getDeclarationOfExpression(expression: ts.Expression): Declaration|null { protected override getDeclarationOfExpression(expression: ts.Expression): Declaration|null {
const inner = getInnerClassDeclaration(expression); const inner = getInnerClassDeclaration(expression);
if (inner !== null) { if (inner !== null) {
const outer = getOuterNodeFromInnerDeclaration(inner); const outer = getOuterNodeFromInnerDeclaration(inner);

View File

@ -175,7 +175,8 @@ export class EntryPointManifest {
* is called. * is called.
*/ */
export class InvalidatingEntryPointManifest extends EntryPointManifest { export class InvalidatingEntryPointManifest extends EntryPointManifest {
readEntryPointsUsingManifest(_basePath: AbsoluteFsPath): EntryPointWithDependencies[]|null { override readEntryPointsUsingManifest(_basePath: AbsoluteFsPath):
EntryPointWithDependencies[]|null {
return null; return null;
} }
} }

View File

@ -26,7 +26,8 @@ export class NgccSourcesCompilerHost extends NgtscCompilerHost {
super(fs, options); super(fs, options);
} }
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile|undefined { override getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile
|undefined {
return this.cache.getCachedSourceFile(fileName, languageVersion); return this.cache.getCachedSourceFile(fileName, languageVersion);
} }
@ -78,7 +79,8 @@ export class NgccDtsCompilerHost extends NgtscCompilerHost {
super(fs, options); super(fs, options);
} }
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile|undefined { override getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile
|undefined {
return this.cache.getCachedSourceFile(fileName, languageVersion); return this.cache.getCachedSourceFile(fileName, languageVersion);
} }

View File

@ -31,7 +31,7 @@ export class CommonJsRenderingFormatter extends Esm5RenderingFormatter {
/** /**
* Add the imports below any in situ imports as `require` calls. * Add the imports below any in situ imports as `require` calls.
*/ */
addImports(output: MagicString, imports: Import[], file: ts.SourceFile): void { override addImports(output: MagicString, imports: Import[], file: ts.SourceFile): void {
// Avoid unnecessary work if there are no imports to add. // Avoid unnecessary work if there are no imports to add.
if (imports.length === 0) { if (imports.length === 0) {
return; return;
@ -46,7 +46,7 @@ export class CommonJsRenderingFormatter extends Esm5RenderingFormatter {
/** /**
* Add the exports to the bottom of the file. * Add the exports to the bottom of the file.
*/ */
addExports( override addExports(
output: MagicString, entryPointBasePath: string, exports: ExportInfo[], output: MagicString, entryPointBasePath: string, exports: ExportInfo[],
importManager: ImportManager, file: ts.SourceFile): void { importManager: ImportManager, file: ts.SourceFile): void {
exports.forEach(e => { exports.forEach(e => {
@ -61,7 +61,7 @@ export class CommonJsRenderingFormatter extends Esm5RenderingFormatter {
}); });
} }
addDirectExports( override addDirectExports(
output: MagicString, exports: Reexport[], importManager: ImportManager, output: MagicString, exports: Reexport[], importManager: ImportManager,
file: ts.SourceFile): void { file: ts.SourceFile): void {
for (const e of exports) { for (const e of exports) {
@ -72,7 +72,7 @@ export class CommonJsRenderingFormatter extends Esm5RenderingFormatter {
} }
} }
protected findEndOfImports(sf: ts.SourceFile): number { protected override findEndOfImports(sf: ts.SourceFile): number {
for (const statement of sf.statements) { for (const statement of sf.statements) {
if (ts.isExpressionStatement(statement) && isRequireCall(statement.expression)) { if (ts.isExpressionStatement(statement) && isRequireCall(statement.expression)) {
continue; continue;

View File

@ -24,7 +24,8 @@ export class Esm5RenderingFormatter extends EsmRenderingFormatter {
* Add the definitions, directly before the return statement, inside the IIFE of each decorated * Add the definitions, directly before the return statement, inside the IIFE of each decorated
* class. * class.
*/ */
addDefinitions(output: MagicString, compiledClass: CompiledClass, definitions: string): void { override addDefinitions(output: MagicString, compiledClass: CompiledClass, definitions: string):
void {
const classSymbol = this.host.getClassSymbol(compiledClass.declaration); const classSymbol = this.host.getClassSymbol(compiledClass.declaration);
if (!classSymbol) { if (!classSymbol) {
throw new Error( throw new Error(
@ -63,7 +64,8 @@ export class Esm5RenderingFormatter extends EsmRenderingFormatter {
* *
* @return The JavaScript code corresponding to `stmt` (in the appropriate format). * @return The JavaScript code corresponding to `stmt` (in the appropriate format).
*/ */
printStatement(stmt: Statement, sourceFile: ts.SourceFile, importManager: ImportManager): string { override printStatement(stmt: Statement, sourceFile: ts.SourceFile, importManager: ImportManager):
string {
const node = translateStatement( const node = translateStatement(
stmt, importManager, {downlevelTaggedTemplates: true, downlevelVariableDeclarations: true}); stmt, importManager, {downlevelTaggedTemplates: true, downlevelVariableDeclarations: true});
const code = this.printer.printNode(ts.EmitHint.Unspecified, node, sourceFile); const code = this.printer.printNode(ts.EmitHint.Unspecified, node, sourceFile);

View File

@ -50,7 +50,7 @@ export class UmdRenderingFormatter extends Esm5RenderingFormatter {
* *
* (See that the `z` import is not being used by the factory function.) * (See that the `z` import is not being used by the factory function.)
*/ */
addImports(output: MagicString, imports: Import[], file: ts.SourceFile): void { override addImports(output: MagicString, imports: Import[], file: ts.SourceFile): void {
if (imports.length === 0) { if (imports.length === 0) {
return; return;
} }
@ -73,7 +73,7 @@ export class UmdRenderingFormatter extends Esm5RenderingFormatter {
/** /**
* Add the exports to the bottom of the UMD module factory function. * Add the exports to the bottom of the UMD module factory function.
*/ */
addExports( override addExports(
output: MagicString, entryPointBasePath: string, exports: ExportInfo[], output: MagicString, entryPointBasePath: string, exports: ExportInfo[],
importManager: ImportManager, file: ts.SourceFile): void { importManager: ImportManager, file: ts.SourceFile): void {
const umdModule = this.umdHost.getUmdModule(file); const umdModule = this.umdHost.getUmdModule(file);
@ -97,7 +97,7 @@ export class UmdRenderingFormatter extends Esm5RenderingFormatter {
}); });
} }
addDirectExports( override addDirectExports(
output: MagicString, exports: Reexport[], importManager: ImportManager, output: MagicString, exports: Reexport[], importManager: ImportManager,
file: ts.SourceFile): void { file: ts.SourceFile): void {
const umdModule = this.umdHost.getUmdModule(file); const umdModule = this.umdHost.getUmdModule(file);
@ -120,7 +120,7 @@ export class UmdRenderingFormatter extends Esm5RenderingFormatter {
/** /**
* Add the constants to the top of the UMD factory function. * Add the constants to the top of the UMD factory function.
*/ */
addConstants(output: MagicString, constants: string, file: ts.SourceFile): void { override addConstants(output: MagicString, constants: string, file: ts.SourceFile): void {
if (constants === '') { if (constants === '') {
return; return;
} }

View File

@ -34,7 +34,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
super(fs, logger, errorOnFailedEntryPoint); super(fs, logger, errorOnFailedEntryPoint);
} }
writeBundle( override writeBundle(
bundle: EntryPointBundle, transformedFiles: FileToWrite[], bundle: EntryPointBundle, transformedFiles: FileToWrite[],
formatProperties: EntryPointJsonProperty[]) { formatProperties: EntryPointJsonProperty[]) {
// The new folder is at the root of the overall package // The new folder is at the root of the overall package
@ -45,7 +45,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
this.updatePackageJson(entryPoint, formatProperties, ngccFolder); this.updatePackageJson(entryPoint, formatProperties, ngccFolder);
} }
revertBundle( override revertBundle(
entryPoint: EntryPoint, transformedFilePaths: AbsoluteFsPath[], entryPoint: EntryPoint, transformedFilePaths: AbsoluteFsPath[],
formatProperties: EntryPointJsonProperty[]): void { formatProperties: EntryPointJsonProperty[]): void {
// IMPLEMENTATION NOTE: // IMPLEMENTATION NOTE:

View File

@ -323,7 +323,8 @@ class TestHandler implements DecoratorHandler<unknown, unknown, null, unknown> {
} }
class AlwaysDetectHandler extends TestHandler { class AlwaysDetectHandler extends TestHandler {
detect(node: ClassDeclaration, decorators: Decorator[]|null): DetectResult<unknown>|undefined { override detect(node: ClassDeclaration, decorators: Decorator[]|null):
DetectResult<unknown>|undefined {
super.detect(node, decorators); super.detect(node, decorators);
const decorator = decorators !== null ? decorators[0] : null; const decorator = decorators !== null ? decorators[0] : null;
return {trigger: node, decorator, metadata: {}}; return {trigger: node, decorator, metadata: {}};
@ -331,11 +332,12 @@ class AlwaysDetectHandler extends TestHandler {
} }
class DetectDecoratorHandler extends TestHandler { class DetectDecoratorHandler extends TestHandler {
constructor(private decorator: string, readonly precedence: HandlerPrecedence) { constructor(private decorator: string, override readonly precedence: HandlerPrecedence) {
super(decorator, []); super(decorator, []);
} }
detect(node: ClassDeclaration, decorators: Decorator[]|null): DetectResult<unknown>|undefined { override detect(node: ClassDeclaration, decorators: Decorator[]|null):
DetectResult<unknown>|undefined {
super.detect(node, decorators); super.detect(node, decorators);
if (decorators === null) { if (decorators === null) {
return undefined; return undefined;
@ -349,7 +351,7 @@ class DetectDecoratorHandler extends TestHandler {
} }
class DiagnosticProducingHandler extends AlwaysDetectHandler { class DiagnosticProducingHandler extends AlwaysDetectHandler {
analyze(node: ClassDeclaration): AnalysisOutput<any> { override analyze(node: ClassDeclaration): AnalysisOutput<any> {
super.analyze(node); super.analyze(node);
return {diagnostics: [makeDiagnostic(9999, node, 'test diagnostic')]}; return {diagnostics: [makeDiagnostic(9999, node, 'test diagnostic')]};
} }

View File

@ -2506,7 +2506,7 @@ runInEachFileSystem(() => {
const externalLibWithoutTypingsIndex = _('/an_external_lib_without_typings/index.js'); const externalLibWithoutTypingsIndex = _('/an_external_lib_without_typings/index.js');
class TestEsm2015ReflectionHost extends Esm2015ReflectionHost { class TestEsm2015ReflectionHost extends Esm2015ReflectionHost {
getExportsOfModule(node: ts.Node) { override getExportsOfModule(node: ts.Node) {
if (ts.isSourceFile(node) && (node.fileName === externalLibWithoutTypingsIndex)) { if (ts.isSourceFile(node) && (node.fileName === externalLibWithoutTypingsIndex)) {
throw new Error( throw new Error(
`'getExportsOfModule()' called on '${externalLibWithoutTypingsIndex}'.`); `'getExportsOfModule()' called on '${externalLibWithoutTypingsIndex}'.`);

View File

@ -28,20 +28,20 @@ runInEachFileSystem(() => {
super(fs, new MockLogger()); super(fs, new MockLogger());
fs.ensureDir(fs.dirname(this.path)); fs.ensureDir(fs.dirname(this.path));
} }
remove() { override remove() {
this.log.push('remove()'); this.log.push('remove()');
super.remove(); super.remove();
} }
write() { override write() {
this.log.push('write()'); this.log.push('write()');
super.write(); super.write();
} }
read() { override read() {
const contents = super.read(); const contents = super.read();
this.log.push('read() => ' + contents); this.log.push('read() => ' + contents);
return contents; return contents;
} }
createUnlocker(): ChildProcess { override createUnlocker(): ChildProcess {
this.log = this.log || []; this.log = this.log || [];
this.log.push('createUnlocker()'); this.log.push('createUnlocker()');
const log = this.log; const log = this.log;

View File

@ -123,7 +123,8 @@ export class ComponentSymbol extends DirectiveSymbol {
usedPipes: SemanticReference[] = []; usedPipes: SemanticReference[] = [];
isRemotelyScoped = false; isRemotelyScoped = false;
isEmitAffected(previousSymbol: SemanticSymbol, publicApiAffected: Set<SemanticSymbol>): boolean { override isEmitAffected(previousSymbol: SemanticSymbol, publicApiAffected: Set<SemanticSymbol>):
boolean {
if (!(previousSymbol instanceof ComponentSymbol)) { if (!(previousSymbol instanceof ComponentSymbol)) {
return true; return true;
} }
@ -146,7 +147,7 @@ export class ComponentSymbol extends DirectiveSymbol {
!isArrayEqual(this.usedPipes, previousSymbol.usedPipes, isSymbolUnaffected); !isArrayEqual(this.usedPipes, previousSymbol.usedPipes, isSymbolUnaffected);
} }
isTypeCheckBlockAffected( override isTypeCheckBlockAffected(
previousSymbol: SemanticSymbol, typeCheckApiAffected: Set<SemanticSymbol>): boolean { previousSymbol: SemanticSymbol, typeCheckApiAffected: Set<SemanticSymbol>): boolean {
if (!(previousSymbol instanceof ComponentSymbol)) { if (!(previousSymbol instanceof ComponentSymbol)) {
return true; return true;

View File

@ -67,7 +67,7 @@ export class NgModuleSymbol extends SemanticSymbol {
return false; return false;
} }
isEmitAffected(previousSymbol: SemanticSymbol): boolean { override isEmitAffected(previousSymbol: SemanticSymbol): boolean {
if (!(previousSymbol instanceof NgModuleSymbol)) { if (!(previousSymbol instanceof NgModuleSymbol)) {
return true; return true;
} }

View File

@ -153,7 +153,7 @@ runInEachFileSystem(() => {
super(checker); super(checker);
} }
hasBaseClass(_class: ClassDeclaration): boolean { override hasBaseClass(_class: ClassDeclaration): boolean {
return hasBaseClass; return hasBaseClass;
} }
} }

View File

@ -38,7 +38,7 @@ export class MockFileSystemNative extends MockFileSystem {
return NodeJSFileSystem.prototype.basename.call(this, filePath, extension); return NodeJSFileSystem.prototype.basename.call(this, filePath, extension);
} }
isCaseSensitive() { override isCaseSensitive() {
return NodeJSFileSystem.prototype.isCaseSensitive.call(this); return NodeJSFileSystem.prototype.isCaseSensitive.call(this);
} }
@ -46,7 +46,7 @@ export class MockFileSystemNative extends MockFileSystem {
return NodeJSFileSystem.prototype.isRooted.call(this, path); return NodeJSFileSystem.prototype.isRooted.call(this, path);
} }
isRoot(path: AbsoluteFsPath): boolean { override isRoot(path: AbsoluteFsPath): boolean {
return NodeJSFileSystem.prototype.isRoot.call(this, path); return NodeJSFileSystem.prototype.isRoot.call(this, path);
} }

View File

@ -175,7 +175,7 @@ runInEachFileSystem(() => {
it('should enumerate exports with the ReflectionHost', () => { it('should enumerate exports with the ReflectionHost', () => {
// Use a modified ReflectionHost that prefixes all export names that it enumerates. // Use a modified ReflectionHost that prefixes all export names that it enumerates.
class TestHost extends TypeScriptReflectionHost { class TestHost extends TypeScriptReflectionHost {
getExportsOfModule(node: ts.Node): Map<string, Declaration>|null { override getExportsOfModule(node: ts.Node): Map<string, Declaration>|null {
const realExports = super.getExportsOfModule(node); const realExports = super.getExportsOfModule(node);
if (realExports === null) { if (realExports === null) {
return null; return null;

View File

@ -62,21 +62,21 @@ class ExpressionVisitor extends RecursiveAstVisitor {
return visitor.identifiers; return visitor.identifiers;
} }
visit(ast: AST) { override visit(ast: AST) {
ast.visit(this); ast.visit(this);
} }
visitMethodCall(ast: MethodCall, context: {}) { override visitMethodCall(ast: MethodCall, context: {}) {
this.visitIdentifier(ast, IdentifierKind.Method); this.visitIdentifier(ast, IdentifierKind.Method);
super.visitMethodCall(ast, context); super.visitMethodCall(ast, context);
} }
visitPropertyRead(ast: PropertyRead, context: {}) { override visitPropertyRead(ast: PropertyRead, context: {}) {
this.visitIdentifier(ast, IdentifierKind.Property); this.visitIdentifier(ast, IdentifierKind.Property);
super.visitPropertyRead(ast, context); super.visitPropertyRead(ast, context);
} }
visitPropertyWrite(ast: PropertyWrite, context: {}) { override visitPropertyWrite(ast: PropertyWrite, context: {}) {
this.visitIdentifier(ast, IdentifierKind.Property); this.visitIdentifier(ast, IdentifierKind.Property);
super.visitPropertyWrite(ast, context); super.visitPropertyWrite(ast, context);
} }
@ -165,7 +165,7 @@ class TemplateVisitor extends TmplAstRecursiveVisitor {
* *
* @param element * @param element
*/ */
visitElement(element: TmplAstElement) { override visitElement(element: TmplAstElement) {
const elementIdentifier = this.elementOrTemplateToIdentifier(element); const elementIdentifier = this.elementOrTemplateToIdentifier(element);
this.identifiers.add(elementIdentifier); this.identifiers.add(elementIdentifier);
@ -176,7 +176,7 @@ class TemplateVisitor extends TmplAstRecursiveVisitor {
this.visitAll(element.children); this.visitAll(element.children);
this.visitAll(element.outputs); this.visitAll(element.outputs);
} }
visitTemplate(template: TmplAstTemplate) { override visitTemplate(template: TmplAstTemplate) {
const templateIdentifier = this.elementOrTemplateToIdentifier(template); const templateIdentifier = this.elementOrTemplateToIdentifier(template);
this.identifiers.add(templateIdentifier); this.identifiers.add(templateIdentifier);
@ -187,7 +187,7 @@ class TemplateVisitor extends TmplAstRecursiveVisitor {
this.visitAll(template.children); this.visitAll(template.children);
this.visitAll(template.references); this.visitAll(template.references);
} }
visitBoundAttribute(attribute: TmplAstBoundAttribute) { override visitBoundAttribute(attribute: TmplAstBoundAttribute) {
// If the bound attribute has no value, it cannot have any identifiers in the value expression. // If the bound attribute has no value, it cannot have any identifiers in the value expression.
if (attribute.valueSpan === undefined) { if (attribute.valueSpan === undefined) {
return; return;
@ -198,18 +198,18 @@ class TemplateVisitor extends TmplAstRecursiveVisitor {
this.boundTemplate, this.targetToIdentifier.bind(this)); this.boundTemplate, this.targetToIdentifier.bind(this));
identifiers.forEach(id => this.identifiers.add(id)); identifiers.forEach(id => this.identifiers.add(id));
} }
visitBoundEvent(attribute: TmplAstBoundEvent) { override visitBoundEvent(attribute: TmplAstBoundEvent) {
this.visitExpression(attribute.handler); this.visitExpression(attribute.handler);
} }
visitBoundText(text: TmplAstBoundText) { override visitBoundText(text: TmplAstBoundText) {
this.visitExpression(text.value); this.visitExpression(text.value);
} }
visitReference(reference: TmplAstReference) { override visitReference(reference: TmplAstReference) {
const referenceIdentifer = this.targetToIdentifier(reference); const referenceIdentifer = this.targetToIdentifier(reference);
this.identifiers.add(referenceIdentifer); this.identifiers.add(referenceIdentifer);
} }
visitVariable(variable: TmplAstVariable) { override visitVariable(variable: TmplAstVariable) {
const variableIdentifier = this.targetToIdentifier(variable); const variableIdentifier = this.targetToIdentifier(variable);
this.identifiers.add(variableIdentifier); this.identifiers.add(variableIdentifier);

View File

@ -1036,7 +1036,7 @@ runInEachFileSystem(() => {
}); });
class DownleveledEnumReflectionHost extends TypeScriptReflectionHost { class DownleveledEnumReflectionHost extends TypeScriptReflectionHost {
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
const declaration = super.getDeclarationOfIdentifier(id); const declaration = super.getDeclarationOfIdentifier(id);
if (declaration !== null && isConcreteDeclaration(declaration)) { if (declaration !== null && isConcreteDeclaration(declaration)) {
const enumMembers = [ const enumMembers = [
@ -1055,7 +1055,7 @@ runInEachFileSystem(() => {
* TypeScript host, as only ngcc's ES5 hosts will have special powers to recognize such functions. * TypeScript host, as only ngcc's ES5 hosts will have special powers to recognize such functions.
*/ */
class TsLibAwareReflectionHost extends TypeScriptReflectionHost { class TsLibAwareReflectionHost extends TypeScriptReflectionHost {
getExportsOfModule(node: ts.Node): Map<string, Declaration>|null { override getExportsOfModule(node: ts.Node): Map<string, Declaration>|null {
const map = super.getExportsOfModule(node); const map = super.getExportsOfModule(node);
if (map !== null) { if (map !== null) {
@ -1065,7 +1065,7 @@ runInEachFileSystem(() => {
return map; return map;
} }
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null { override getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
const superDeclaration = super.getDeclarationOfIdentifier(id); const superDeclaration = super.getDeclarationOfIdentifier(id);
if (superDeclaration === null || superDeclaration.node === null) { if (superDeclaration === null || superDeclaration.node === null) {

View File

@ -15,7 +15,8 @@ import {getCachedSourceFile} from './cached_source_files';
* reuse across tests. * reuse across tests.
*/ */
export class NgtscTestCompilerHost extends NgtscCompilerHost { export class NgtscTestCompilerHost extends NgtscCompilerHost {
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile|undefined { override getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile
|undefined {
const cachedSf = getCachedSourceFile(fileName, () => this.readFile(fileName)); const cachedSf = getCachedSourceFile(fileName, () => this.readFile(fileName));
if (cachedSf !== null) { if (cachedSf !== null) {
return cachedSf; return cachedSf;

View File

@ -22,7 +22,7 @@ export class ExpressionSemanticVisitor extends RecursiveAstVisitor {
super(); super();
} }
visitPropertyWrite(ast: PropertyWrite, context: any): void { override visitPropertyWrite(ast: PropertyWrite, context: any): void {
super.visitPropertyWrite(ast, context); super.visitPropertyWrite(ast, context);
if (!(ast.receiver instanceof ImplicitReceiver)) { if (!(ast.receiver instanceof ImplicitReceiver)) {

View File

@ -471,7 +471,7 @@ abstract class TcbDirectiveTypeOpBase extends TcbOp {
/** /**
* A `TcbOp` which constructs an instance of a non-generic directive _without_ setting any of its * A `TcbOp` which constructs an instance of a non-generic directive _without_ setting any of its
* inputs. Inputs are later set in the `TcbDirectiveInputsOp`. Type checking was found to be * inputs. Inputs are later set in the `TcbDirectiveInputsOp`. Type checking was found to be
* faster when done in this way as opposed to `TcbDirectiveCtorOp` which is only necessary when the * faster when done in this way as opposed to `TcbDirectiveCtorOp` which is only necessary when the
* directive is generic. * directive is generic.
* *
@ -483,7 +483,7 @@ class TcbNonGenericDirectiveTypeOp extends TcbDirectiveTypeOpBase {
* Creates a variable declaration for this op's directive of the argument type. Returns the id of * Creates a variable declaration for this op's directive of the argument type. Returns the id of
* the newly created variable. * the newly created variable.
*/ */
execute(): ts.Identifier { override execute(): ts.Identifier {
const dirRef = this.dir.ref as Reference<ClassDeclaration<ts.ClassDeclaration>>; const dirRef = this.dir.ref as Reference<ClassDeclaration<ts.ClassDeclaration>>;
if (this.dir.isGeneric) { if (this.dir.isGeneric) {
throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`); throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`);
@ -501,7 +501,7 @@ class TcbNonGenericDirectiveTypeOp extends TcbDirectiveTypeOpBase {
* type parameters set to `any`. * type parameters set to `any`.
*/ */
class TcbGenericDirectiveTypeWithAnyParamsOp extends TcbDirectiveTypeOpBase { class TcbGenericDirectiveTypeWithAnyParamsOp extends TcbDirectiveTypeOpBase {
execute(): ts.Identifier { override execute(): ts.Identifier {
const dirRef = this.dir.ref as Reference<ClassDeclaration<ts.ClassDeclaration>>; const dirRef = this.dir.ref as Reference<ClassDeclaration<ts.ClassDeclaration>>;
if (dirRef.node.typeParameters === undefined) { if (dirRef.node.typeParameters === undefined) {
throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${ throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${
@ -671,7 +671,7 @@ class TcbDirectiveCtorOp extends TcbOp {
return id; return id;
} }
circularFallback(): TcbOp { override circularFallback(): TcbOp {
return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.node, this.dir); return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.node, this.dir);
} }
} }
@ -1980,7 +1980,7 @@ function tcbEventHandlerExpression(ast: AST, tcb: Context, scope: Scope): ts.Exp
} }
class TcbEventHandlerTranslator extends TcbExpressionTranslator { class TcbEventHandlerTranslator extends TcbExpressionTranslator {
protected resolve(ast: AST): ts.Expression|null { protected override resolve(ast: AST): ts.Expression|null {
// Recognize a property read on the implicit receiver corresponding with the event parameter // Recognize a property read on the implicit receiver corresponding with the event parameter
// that is available in event bindings. Since this variable is a parameter of the handler // that is available in event bindings. Since this variable is a parameter of the handler
// function that the converted expression becomes a child of, just create a reference to the // function that the converted expression becomes a child of, just create a reference to the

View File

@ -77,7 +77,7 @@ export class TypeCheckFile extends Environment {
return source; return source;
} }
getPreludeStatements(): ts.Statement[] { override getPreludeStatements(): ts.Statement[] {
return []; return [];
} }
} }

View File

@ -45,10 +45,8 @@ export abstract class Visitor {
* Visit a class declaration, returning at least the transformed declaration and optionally other * Visit a class declaration, returning at least the transformed declaration and optionally other
* nodes to insert before the declaration. * nodes to insert before the declaration.
*/ */
visitClassDeclaration(node: ts.ClassDeclaration): abstract visitClassDeclaration(node: ts.ClassDeclaration):
VisitListEntryResult<ts.Statement, ts.ClassDeclaration> { VisitListEntryResult<ts.Statement, ts.ClassDeclaration>;
return {node};
}
private _visitListEntryNode<T extends ts.Statement>( private _visitListEntryNode<T extends ts.Statement>(
node: T, visitor: (node: T) => VisitListEntryResult<ts.Statement, T>): T { node: T, visitor: (node: T) => VisitListEntryResult<ts.Statement, T>): T {

View File

@ -149,9 +149,6 @@ export class MockNode implements ts.Node {
export class MockIdentifier extends MockNode implements ts.Identifier { export class MockIdentifier extends MockNode implements ts.Identifier {
originalKeywordKind?: ts.SyntaxKind; originalKeywordKind?: ts.SyntaxKind;
isInJSDocNamespace?: boolean; isInJSDocNamespace?: boolean;
decorators?: ts.NodeArray<ts.Decorator>;
modifiers?: ts.NodeArray<ts.Modifier>;
parent!: ts.Node;
public text: string; public text: string;
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.
public escapedText!: ts.__String; public escapedText!: ts.__String;
@ -167,7 +164,8 @@ export class MockIdentifier extends MockNode implements ts.Identifier {
// tslint:enable // tslint:enable
constructor( constructor(
public name: string, public kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier, public name: string,
public override kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier,
flags: ts.NodeFlags = 0, pos: number = 0, end: number = 0) { flags: ts.NodeFlags = 0, pos: number = 0, end: number = 0) {
super(kind, flags, pos, end); super(kind, flags, pos, end);
this.text = name; this.text = name;
@ -175,18 +173,16 @@ export class MockIdentifier extends MockNode implements ts.Identifier {
} }
export class MockVariableDeclaration extends MockNode implements ts.VariableDeclaration { export class MockVariableDeclaration extends MockNode implements ts.VariableDeclaration {
parent!: ts.VariableDeclarationList|ts.CatchClause; override parent!: ts.VariableDeclarationList|ts.CatchClause;
exclamationToken?: ts.Token<ts.SyntaxKind.ExclamationToken>; exclamationToken?: ts.Token<ts.SyntaxKind.ExclamationToken>;
type?: ts.TypeNode; type?: ts.TypeNode;
initializer?: ts.Expression; initializer?: ts.Expression;
decorators?: ts.NodeArray<ts.Decorator>;
modifiers?: ts.NodeArray<ts.Modifier>;
// tslint:disable-next-line // tslint:disable-next-line
public _declarationBrand: any; public _declarationBrand: any;
constructor( constructor(
public name: ts.Identifier, public name: ts.Identifier,
public kind: ts.SyntaxKind.VariableDeclaration = ts.SyntaxKind.VariableDeclaration, public override kind: ts.SyntaxKind.VariableDeclaration = ts.SyntaxKind.VariableDeclaration,
flags: ts.NodeFlags = 0, pos: number = 0, end: number = 0) { flags: ts.NodeFlags = 0, pos: number = 0, end: number = 0) {
super(kind, flags, pos, end); super(kind, flags, pos, end);
} }

View File

@ -329,7 +329,7 @@ class MultiCompileHostExt extends AugmentedCompilerHost implements Partial<ts.Co
private cache = new Map<string, ts.SourceFile>(); private cache = new Map<string, ts.SourceFile>();
private writtenFiles = new Set<string>(); private writtenFiles = new Set<string>();
getSourceFile( override getSourceFile(
fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void, fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void,
shouldCreateNewSourceFile?: boolean): ts.SourceFile|undefined { shouldCreateNewSourceFile?: boolean): ts.SourceFile|undefined {
if (this.cache.has(fileName)) { if (this.cache.has(fileName)) {
@ -346,7 +346,7 @@ class MultiCompileHostExt extends AugmentedCompilerHost implements Partial<ts.Co
this.writtenFiles.clear(); this.writtenFiles.clear();
} }
writeFile( override writeFile(
fileName: string, data: string, writeByteOrderMark: boolean, fileName: string, data: string, writeByteOrderMark: boolean,
onError: ((message: string) => void)|undefined, onError: ((message: string) => void)|undefined,
sourceFiles?: ReadonlyArray<ts.SourceFile>): void { sourceFiles?: ReadonlyArray<ts.SourceFile>): void {