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

Function getThisType

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

Source from the content-addressed store, hash-verified

63088 return esSymbolType;
63089 }
63090 function getThisType(node) {
63091 var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
63092 var parent = container && container.parent;
63093 if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) {
63094 if (!ts.isStatic(container) &&
63095 (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
63096 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
63097 }
63098 }
63099 // inside x.prototype = { ... }
63100 if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) {
63101 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
63102 }
63103 // /** @return {this} */
63104 // x.prototype.m = function() { ... }
63105 var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
63106 if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) {
63107 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
63108 }
63109 // inside constructor function C() { ... }
63110 if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
63111 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
63112 }
63113 error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
63114 return errorType;
63115 }
63116 function getTypeFromThisTypeNode(node) {
63117 var links = getNodeLinks(node);
63118 if (!links.resolvedType) {

Callers 1

getTypeFromThisTypeNodeFunction · 0.85

Calls 4

getSymbolOfNodeFunction · 0.85
isJSConstructorFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…