MCPcopy Index your code
hub / github.com/nodejs/node / checkClassLikeDeclaration

Function checkClassLikeDeclaration

test/fixtures/snapshot/typescript.js:84082–84196  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

84080 registerForUnusedIdentifiersCheck(node);
84081 }
84082 function checkClassLikeDeclaration(node) {
84083 checkGrammarClassLikeDeclaration(node);
84084 checkDecorators(node);
84085 checkCollisionsForDeclarationName(node, node.name);
84086 checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
84087 checkExportsOnMergedDeclarations(node);
84088 var symbol = getSymbolOfNode(node);
84089 var type = getDeclaredTypeOfSymbol(symbol);
84090 var typeWithThis = getTypeWithThisArgument(type);
84091 var staticType = getTypeOfSymbol(symbol);
84092 checkTypeParameterListsIdentical(symbol);
84093 checkFunctionOrConstructorSymbol(symbol);
84094 checkClassForDuplicateDeclarations(node);
84095 // Only check for reserved static identifiers on non-ambient context.
84096 var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */);
84097 if (!nodeInAmbientContext) {
84098 checkClassForStaticPropertyNameConflicts(node);
84099 }
84100 var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
84101 if (baseTypeNode) {
84102 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
84103 if (languageVersion < 2 /* ScriptTarget.ES2015 */) {
84104 checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */);
84105 }
84106 // check both @extends and extends if both are specified.
84107 var extendsNode = ts.getClassExtendsHeritageElement(node);
84108 if (extendsNode && extendsNode !== baseTypeNode) {
84109 checkExpression(extendsNode.expression);
84110 }
84111 var baseTypes_2 = getBaseTypes(type);
84112 if (baseTypes_2.length) {
84113 addLazyDiagnostic(function () {
84114 var baseType = baseTypes_2[0];
84115 var baseConstructorType = getBaseConstructorTypeOfClass(type);
84116 var staticBaseType = getApparentType(baseConstructorType);
84117 checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
84118 checkSourceElement(baseTypeNode.expression);
84119 if (ts.some(baseTypeNode.typeArguments)) {
84120 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
84121 for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
84122 var constructor = _a[_i];
84123 if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
84124 break;
84125 }
84126 }
84127 }
84128 var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
84129 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
84130 issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
84131 }
84132 else {
84133 // Report static side error only when instance type is assignable
84134 checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
84135 }
84136 if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) {
84137 if (!isMixinConstructorType(staticType)) {
84138 error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
84139 }

Callers 2

checkClassExpressionFunction · 0.85
checkClassDeclarationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…