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

Function isConstraintPosition

test/fixtures/snapshot/typescript.js:71486–71496  ·  view source on GitHub ↗
(type, node)

Source from the content-addressed store, hash-verified

71484 }
71485 }
71486 function isConstraintPosition(type, node) {
71487 var parent = node.parent;
71488 // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of
71489 // a generic type without a nullable constraint and x is a generic type. This is because when both obj
71490 // and x are of generic types T and K, we want the resulting type to be T[K].
71491 return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ||
71492 parent.kind === 161 /* SyntaxKind.QualifiedName */ ||
71493 parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node ||
71494 parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node &&
71495 !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
71496 }
71497 function isGenericTypeWithUnionConstraint(type) {
71498 return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */));
71499 }

Callers 1

Calls 3

someTypeFunction · 0.85
isGenericIndexTypeFunction · 0.85
getTypeOfExpressionFunction · 0.85

Tested by

no test coverage detected