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

Function getDefaultConstraintOfConditionalType

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

Source from the content-addressed store, hash-verified

58847 return undefined;
58848 }
58849 function getDefaultConstraintOfConditionalType(type) {
58850 if (!type.resolvedDefaultConstraint) {
58851 // An `any` branch of a conditional type would normally be viral - specifically, without special handling here,
58852 // a conditional type with a single branch of type `any` would be assignable to anything, since it's constraint would simplify to
58853 // just `any`. This result is _usually_ unwanted - so instead here we elide an `any` branch from the constraint type,
58854 // in effect treating `any` like `never` rather than `unknown` in this location.
58855 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
58856 var falseConstraint = getFalseTypeFromConditionalType(type);
58857 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
58858 }
58859 return type.resolvedDefaultConstraint;
58860 }
58861 function getConstraintOfDistributiveConditionalType(type) {
58862 // Check if we have a conditional type of the form 'T extends U ? X : Y', where T is a constrained
58863 // type parameter. If so, create an instantiation of the conditional type where T is replaced

Callers 3

structuredTypeRelatedToFunction · 0.85
hasPrimitiveConstraintFunction · 0.85

Calls 4

isTypeAnyFunction · 0.85
getUnionTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…