Revert to declared type when '!' postfix operator would produce 'nothing'
This commit is contained in:
parent
8c9348d8d6
commit
5edf72666d
|
@ -7621,6 +7621,9 @@ namespace ts {
|
|||
const visitedFlowStart = visitedFlowCount;
|
||||
const result = getTypeAtFlowNode(reference.flowNode);
|
||||
visitedFlowCount = visitedFlowStart;
|
||||
if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === nothingType) {
|
||||
return declaredType;
|
||||
}
|
||||
return result;
|
||||
|
||||
function getTypeAtFlowNode(flow: FlowNode): Type {
|
||||
|
|
Loading…
Reference in a new issue