MCPcopy
hub / github.com/angular/angular / getBaseClass

Function getBaseClass

tools/tslint/noImplicitOverrideAbstractRule.ts:107–125  ·  view source on GitHub ↗

Gets the base class for the given class declaration.

(
  node: ts.ClassDeclaration,
  typeChecker: ts.TypeChecker,
)

Source from the content-addressed store, hash-verified

105
106/** Gets the base class for the given class declaration. */
107function getBaseClass(
108 node: ts.ClassDeclaration,
109 typeChecker: ts.TypeChecker,
110): ts.ClassDeclaration | null {
111 const baseTypes = getExtendsHeritageExpressions(node);
112
113 if (baseTypes.length > 1) {
114 throw Error('Class unexpectedly extends from multiple types.');
115 }
116
117 const baseClass = typeChecker.getTypeAtLocation(baseTypes[0]).getSymbol();
118 const baseClassDecl = baseClass?.valueDeclaration ?? baseClass?.declarations?.[0];
119
120 if (baseClassDecl !== undefined && ts.isClassDeclaration(baseClassDecl)) {
121 return baseClassDecl;
122 }
123
124 return null;
125}
126
127/** Gets the `extends` base type expressions of the specified class. */
128function getExtendsHeritageExpressions(

Calls 3

ErrorInterface · 0.85
getSymbolMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…