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

Function getDeclaredTypeOfClassOrInterface

test/fixtures/snapshot/typescript.js:57349–57382  ·  view source on GitHub ↗
(symbol)

Source from the content-addressed store, hash-verified

57347 return true;
57348 }
57349 function getDeclaredTypeOfClassOrInterface(symbol) {
57350 var links = getSymbolLinks(symbol);
57351 var originalLinks = links;
57352 if (!links.declaredType) {
57353 var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */;
57354 var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration));
57355 if (merged) {
57356 // note:we overwrite links because we just cloned the symbol
57357 symbol = links = merged;
57358 }
57359 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
57360 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
57361 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
57362 // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type
57363 // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular,
57364 // property types inferred from initializers and method return types inferred from return statements are very hard
57365 // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of
57366 // "this" references.
57367 if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) {
57368 type.objectFlags |= 4 /* ObjectFlags.Reference */;
57369 type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
57370 type.outerTypeParameters = outerTypeParameters;
57371 type.localTypeParameters = localTypeParameters;
57372 type.instantiations = new ts.Map();
57373 type.instantiations.set(getTypeListId(type.typeParameters), type);
57374 type.target = type;
57375 type.resolvedTypeArguments = type.typeParameters;
57376 type.thisType = createTypeParameter(symbol);
57377 type.thisType.isThisType = true;
57378 type.thisType.constraint = type;
57379 }
57380 }
57381 return links.declaredType;
57382 }
57383 function getDeclaredTypeOfTypeAlias(symbol) {
57384 var _a;
57385 var links = getSymbolLinks(symbol);

Callers 14

isClassInstanceSideFunction · 0.85
serializeInterfaceFunction · 0.85
serializeAsClassFunction · 0.85
getOuterTypeParametersFunction · 0.85
isThislessInterfaceFunction · 0.85
getThisTypeFunction · 0.85

Calls 10

getSymbolLinksFunction · 0.85
mergeJSSymbolsFunction · 0.85
getAssignedClassSymbolFunction · 0.85
createObjectTypeFunction · 0.85
isThislessInterfaceFunction · 0.85
getTypeListIdFunction · 0.85
createTypeParameterFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…