From 3045cf5fa2a2ea7657b2030e3acebcc69c3779d0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 21 Apr 2016 10:49:39 -0700 Subject: [PATCH] Add regression test --- .../controlFlowBinaryOrExpression.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/cases/conformance/controlFlow/controlFlowBinaryOrExpression.ts b/tests/cases/conformance/controlFlow/controlFlowBinaryOrExpression.ts index 75b24622e00..9dab32e0cb8 100644 --- a/tests/cases/conformance/controlFlow/controlFlowBinaryOrExpression.ts +++ b/tests/cases/conformance/controlFlow/controlFlowBinaryOrExpression.ts @@ -7,3 +7,29 @@ x; // string | number x = ""; cond || (x = 0); x; // string | number + +export interface NodeList { + length: number; +} + +export interface HTMLCollection { + length: number; +} + +declare function isNodeList(sourceObj: any): sourceObj is NodeList; +declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection; + +type EventTargetLike = {a: string} | HTMLCollection | NodeList; + +var sourceObj: EventTargetLike = undefined; +if (isNodeList(sourceObj)) { + sourceObj.length; +} + +if (isHTMLCollection(sourceObj)) { + sourceObj.length; +} + +if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { + sourceObj.length; +}