Make 'instanceof' behave like TS if the lhs is nullable

This commit is contained in:
dcodeIO
2018-06-09 02:01:45 +02:00
parent 7478c8a0d3
commit 47f2e0950a
8 changed files with 220 additions and 54 deletions

View File

@ -1847,7 +1847,9 @@ export class Program extends DiagnosticEmitter {
if (node.kind == NodeKind.SIGNATURE) {
let signature = this.resolveSignature(<SignatureNode>node, contextualTypeArguments, reportNotFound);
if (!signature) return null;
return Type.u32.asFunction(signature);
return node.isNullable
? signature.type.asNullable()
: signature.type;
}
var typeNode = <TypeNode>node;
var simpleName = typeNode.name.text;
@ -1867,7 +1869,10 @@ export class Program extends DiagnosticEmitter {
contextualTypeArguments,
null
); // reports
return instance ? instance.type : null;
if (!instance) return null;
return node.isNullable
? instance.type.asNullable()
: instance.type;
}
}
}