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

Function removeOptionalityFromDeclaredType

test/fixtures/snapshot/typescript.js:71471–71485  ·  view source on GitHub ↗

remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined)

(declaredType, declaration)

Source from the content-addressed store, hash-verified

71469 }
71470 /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */
71471 function removeOptionalityFromDeclaredType(declaredType, declaration) {
71472 if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) {
71473 var annotationIncludesUndefined = strictNullChecks &&
71474 declaration.kind === 164 /* SyntaxKind.Parameter */ &&
71475 declaration.initializer &&
71476 getFalsyFlags(declaredType) & 32768 /* TypeFlags.Undefined */ &&
71477 !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* TypeFlags.Undefined */);
71478 popTypeResolution();
71479 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType;
71480 }
71481 else {
71482 reportCircularityError(declaration.symbol);
71483 return declaredType;
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

Callers 1

checkIdentifierFunction · 0.85

Calls 6

pushTypeResolutionFunction · 0.85
getFalsyFlagsFunction · 0.85
popTypeResolutionFunction · 0.85
getTypeWithFactsFunction · 0.85
reportCircularityErrorFunction · 0.85
checkExpressionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…