remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined)
(declaredType, declaration)
| 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 |
no test coverage detected
searching dependent graphs…