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

Function isLegalUsageOfSuperExpression

test/fixtures/snapshot/typescript.js:72286–72322  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

72284 ? getBaseConstructorTypeOfClass(classType)
72285 : getTypeWithThisArgument(baseClassType, classType.thisType);
72286 function isLegalUsageOfSuperExpression(container) {
72287 if (!container) {
72288 return false;
72289 }
72290 if (isCallExpression) {
72291 // TS 1.0 SPEC (April 2014): 4.8.1
72292 // Super calls are only permitted in constructors of derived classes
72293 return container.kind === 171 /* SyntaxKind.Constructor */;
72294 }
72295 else {
72296 // TS 1.0 SPEC (April 2014)
72297 // 'super' property access is allowed
72298 // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance
72299 // - In a static member function or static member accessor
72300 // topmost container must be something that is directly nested in the class declaration\object literal expression
72301 if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
72302 if (ts.isStatic(container)) {
72303 return container.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
72304 container.kind === 168 /* SyntaxKind.MethodSignature */ ||
72305 container.kind === 172 /* SyntaxKind.GetAccessor */ ||
72306 container.kind === 173 /* SyntaxKind.SetAccessor */ ||
72307 container.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
72308 container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */;
72309 }
72310 else {
72311 return container.kind === 169 /* SyntaxKind.MethodDeclaration */ ||
72312 container.kind === 168 /* SyntaxKind.MethodSignature */ ||
72313 container.kind === 172 /* SyntaxKind.GetAccessor */ ||
72314 container.kind === 173 /* SyntaxKind.SetAccessor */ ||
72315 container.kind === 167 /* SyntaxKind.PropertyDeclaration */ ||
72316 container.kind === 166 /* SyntaxKind.PropertySignature */ ||
72317 container.kind === 171 /* SyntaxKind.Constructor */;
72318 }
72319 }
72320 }
72321 return false;
72322 }
72323 }
72324 function getContainingObjectLiteral(func) {
72325 return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ ||

Callers 1

checkSuperExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected