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

Function getOuterTypeParameters

test/fixtures/snapshot/typescript.js:56959–57023  ·  view source on GitHub ↗
(node, includeThisTypes)

Source from the content-addressed store, hash-verified

56957 }
56958 // Return the outer type parameters of a node or undefined if the node has no outer type parameters.
56959 function getOuterTypeParameters(node, includeThisTypes) {
56960 while (true) {
56961 node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead
56962 if (node && ts.isBinaryExpression(node)) {
56963 // prototype assignments get the outer type parameters of their constructor function
56964 var assignmentKind = ts.getAssignmentDeclarationKind(node);
56965 if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) {
56966 var symbol = getSymbolOfNode(node.left);
56967 if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
56968 node = symbol.parent.valueDeclaration;
56969 }
56970 }
56971 }
56972 if (!node) {
56973 return undefined;
56974 }
56975 switch (node.kind) {
56976 case 257 /* SyntaxKind.ClassDeclaration */:
56977 case 226 /* SyntaxKind.ClassExpression */:
56978 case 258 /* SyntaxKind.InterfaceDeclaration */:
56979 case 174 /* SyntaxKind.CallSignature */:
56980 case 175 /* SyntaxKind.ConstructSignature */:
56981 case 168 /* SyntaxKind.MethodSignature */:
56982 case 179 /* SyntaxKind.FunctionType */:
56983 case 180 /* SyntaxKind.ConstructorType */:
56984 case 317 /* SyntaxKind.JSDocFunctionType */:
56985 case 256 /* SyntaxKind.FunctionDeclaration */:
56986 case 169 /* SyntaxKind.MethodDeclaration */:
56987 case 213 /* SyntaxKind.FunctionExpression */:
56988 case 214 /* SyntaxKind.ArrowFunction */:
56989 case 259 /* SyntaxKind.TypeAliasDeclaration */:
56990 case 344 /* SyntaxKind.JSDocTemplateTag */:
56991 case 345 /* SyntaxKind.JSDocTypedefTag */:
56992 case 339 /* SyntaxKind.JSDocEnumTag */:
56993 case 338 /* SyntaxKind.JSDocCallbackTag */:
56994 case 195 /* SyntaxKind.MappedType */:
56995 case 189 /* SyntaxKind.ConditionalType */: {
56996 var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
56997 if (node.kind === 195 /* SyntaxKind.MappedType */) {
56998 return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
56999 }
57000 else if (node.kind === 189 /* SyntaxKind.ConditionalType */) {
57001 return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
57002 }
57003 var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
57004 var thisType = includeThisTypes &&
57005 (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) &&
57006 getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
57007 return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
57008 }
57009 case 340 /* SyntaxKind.JSDocParameterTag */:
57010 var paramSymbol = ts.getParameterSymbolFromJSDoc(node);
57011 if (paramSymbol) {
57012 node = paramSymbol.valueDeclaration;
57013 }
57014 break;
57015 case 320 /* SyntaxKind.JSDoc */: {
57016 var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);

Calls 8

getSymbolOfNodeFunction · 0.85
getInferTypeParametersFunction · 0.85
appendTypeParametersFunction · 0.85
isJSConstructorFunction · 0.85
flatMapMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…