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

Function couldContainTypeVariables

test/fixtures/snapshot/typescript.js:68142–68156  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

68140 // we perform type inference (i.e. a type parameter of a generic function). We cache
68141 // results for union and intersection types for performance reasons.
68142 function couldContainTypeVariables(type) {
68143 var objectFlags = ts.getObjectFlags(type);
68144 if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) {
68145 return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */);
68146 }
68147 var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ ||
68148 type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
68149 objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations ||
68150 objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) ||
68151 type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
68152 if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) {
68153 type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0);
68154 }
68155 return result;
68156 }
68157 function isNonGenericTopLevelType(type) {
68158 if (type.aliasSymbol && !type.aliasTypeArguments) {
68159 var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */);

Callers 5

instantiateSymbolFunction · 0.85
instantiateTypeWithAliasFunction · 0.85
inferFromTypesFunction · 0.85
inferTypeArgumentsFunction · 0.85

Calls 4

isNonGenericTopLevelTypeFunction · 0.85
getTypeArgumentsFunction · 0.85
someMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…