Accepting new baselines
This commit is contained in:
parent
3045cf5fa2
commit
06928b669e
10 changed files with 209 additions and 71 deletions
|
@ -9,8 +9,35 @@ 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 = <any>undefined;
|
||||
if (isNodeList(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
|
||||
if (isHTMLCollection(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
|
||||
if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowBinaryOrExpression.js]
|
||||
"use strict";
|
||||
var x;
|
||||
var cond;
|
||||
(x = "") || (x = 0);
|
||||
|
@ -18,3 +45,13 @@ x; // string | number
|
|||
x = "";
|
||||
cond || (x = 0);
|
||||
x; // string | number
|
||||
var sourceObj = undefined;
|
||||
if (isNodeList(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
if (isHTMLCollection(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
|
||||
sourceObj.length;
|
||||
}
|
||||
|
|
|
@ -22,3 +22,72 @@ cond || (x = 0);
|
|||
x; // string | number
|
||||
>x : Symbol(x, Decl(controlFlowBinaryOrExpression.ts, 0, 3))
|
||||
|
||||
export interface NodeList {
|
||||
>NodeList : Symbol(NodeList, Decl(controlFlowBinaryOrExpression.ts, 8, 2))
|
||||
|
||||
length: number;
|
||||
>length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27))
|
||||
}
|
||||
|
||||
export interface HTMLCollection {
|
||||
>HTMLCollection : Symbol(HTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 12, 1))
|
||||
|
||||
length: number;
|
||||
>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
}
|
||||
|
||||
declare function isNodeList(sourceObj: any): sourceObj is NodeList;
|
||||
>isNodeList : Symbol(isNodeList, Decl(controlFlowBinaryOrExpression.ts, 16, 1))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 18, 28))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 18, 28))
|
||||
>NodeList : Symbol(NodeList, Decl(controlFlowBinaryOrExpression.ts, 8, 2))
|
||||
|
||||
declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection;
|
||||
>isHTMLCollection : Symbol(isHTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 18, 67))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 19, 34))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 19, 34))
|
||||
>HTMLCollection : Symbol(HTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 12, 1))
|
||||
|
||||
type EventTargetLike = {a: string} | HTMLCollection | NodeList;
|
||||
>EventTargetLike : Symbol(EventTargetLike, Decl(controlFlowBinaryOrExpression.ts, 19, 79))
|
||||
>a : Symbol(a, Decl(controlFlowBinaryOrExpression.ts, 21, 24))
|
||||
>HTMLCollection : Symbol(HTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 12, 1))
|
||||
>NodeList : Symbol(NodeList, Decl(controlFlowBinaryOrExpression.ts, 8, 2))
|
||||
|
||||
var sourceObj: EventTargetLike = <any>undefined;
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
>EventTargetLike : Symbol(EventTargetLike, Decl(controlFlowBinaryOrExpression.ts, 19, 79))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
if (isNodeList(sourceObj)) {
|
||||
>isNodeList : Symbol(isNodeList, Decl(controlFlowBinaryOrExpression.ts, 16, 1))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
}
|
||||
|
||||
if (isHTMLCollection(sourceObj)) {
|
||||
>isHTMLCollection : Symbol(isHTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 18, 67))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
}
|
||||
|
||||
if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
|
||||
>isNodeList : Symbol(isNodeList, Decl(controlFlowBinaryOrExpression.ts, 16, 1))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
>isHTMLCollection : Symbol(isHTMLCollection, Decl(controlFlowBinaryOrExpression.ts, 18, 67))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
>sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3))
|
||||
>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33))
|
||||
}
|
||||
|
||||
|
|
|
@ -35,3 +35,78 @@ cond || (x = 0);
|
|||
x; // string | number
|
||||
>x : string | number
|
||||
|
||||
export interface NodeList {
|
||||
>NodeList : NodeList
|
||||
|
||||
length: number;
|
||||
>length : number
|
||||
}
|
||||
|
||||
export interface HTMLCollection {
|
||||
>HTMLCollection : HTMLCollection
|
||||
|
||||
length: number;
|
||||
>length : number
|
||||
}
|
||||
|
||||
declare function isNodeList(sourceObj: any): sourceObj is NodeList;
|
||||
>isNodeList : (sourceObj: any) => sourceObj is NodeList
|
||||
>sourceObj : any
|
||||
>sourceObj : any
|
||||
>NodeList : NodeList
|
||||
|
||||
declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection;
|
||||
>isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection
|
||||
>sourceObj : any
|
||||
>sourceObj : any
|
||||
>HTMLCollection : HTMLCollection
|
||||
|
||||
type EventTargetLike = {a: string} | HTMLCollection | NodeList;
|
||||
>EventTargetLike : { a: string; } | HTMLCollection | NodeList
|
||||
>a : string
|
||||
>HTMLCollection : HTMLCollection
|
||||
>NodeList : NodeList
|
||||
|
||||
var sourceObj: EventTargetLike = <any>undefined;
|
||||
>sourceObj : { a: string; } | HTMLCollection | NodeList
|
||||
>EventTargetLike : { a: string; } | HTMLCollection | NodeList
|
||||
><any>undefined : any
|
||||
>undefined : undefined
|
||||
|
||||
if (isNodeList(sourceObj)) {
|
||||
>isNodeList(sourceObj) : boolean
|
||||
>isNodeList : (sourceObj: any) => sourceObj is NodeList
|
||||
>sourceObj : { a: string; } | HTMLCollection
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : number
|
||||
>sourceObj : HTMLCollection
|
||||
>length : number
|
||||
}
|
||||
|
||||
if (isHTMLCollection(sourceObj)) {
|
||||
>isHTMLCollection(sourceObj) : boolean
|
||||
>isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection
|
||||
>sourceObj : HTMLCollection | { a: string; }
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : number
|
||||
>sourceObj : HTMLCollection
|
||||
>length : number
|
||||
}
|
||||
|
||||
if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
|
||||
>isNodeList(sourceObj) || isHTMLCollection(sourceObj) : boolean
|
||||
>isNodeList(sourceObj) : boolean
|
||||
>isNodeList : (sourceObj: any) => sourceObj is NodeList
|
||||
>sourceObj : HTMLCollection | { a: string; }
|
||||
>isHTMLCollection(sourceObj) : boolean
|
||||
>isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection
|
||||
>sourceObj : { a: string; }
|
||||
|
||||
sourceObj.length;
|
||||
>sourceObj.length : number
|
||||
>sourceObj : HTMLCollection
|
||||
>length : number
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ function fn5(x: Derived1) {
|
|||
// 1.5: y: Derived1
|
||||
// Want: ???
|
||||
let y = x;
|
||||
>y : Derived1
|
||||
>x : Derived1
|
||||
>y : {}
|
||||
>x : {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ if (hasKind(x, "A")) {
|
|||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : A
|
||||
>x : A
|
||||
>b : {}
|
||||
>x : {}
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
|
@ -116,6 +116,6 @@ if (!hasKind(x, "B")) {
|
|||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : A
|
||||
>x : A
|
||||
>d : {}
|
||||
>x : {}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ if (hasKind(x, "A")) {
|
|||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : A
|
||||
>x : A
|
||||
>b : {}
|
||||
>x : {}
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
|
@ -110,6 +110,6 @@ if (!hasKind(x, "B")) {
|
|||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : A
|
||||
>x : A
|
||||
>d : {}
|
||||
>x : {}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@ if (hasKind(x, "A")) {
|
|||
}
|
||||
else {
|
||||
let b = x;
|
||||
>b : A
|
||||
>x : A
|
||||
>b : {}
|
||||
>x : {}
|
||||
}
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
|
@ -113,6 +113,6 @@ if (!hasKind(x, "B")) {
|
|||
}
|
||||
else {
|
||||
let d = x;
|
||||
>d : A
|
||||
>x : A
|
||||
>d : {}
|
||||
>x : {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20): error TS2339: Property 'global' does not exist on type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts (1 errors) ====
|
||||
interface I { global: string; }
|
||||
var result: I;
|
||||
var result2: I;
|
||||
|
||||
if (!(result instanceof RegExp)) {
|
||||
result = result2;
|
||||
} else if (!result.global) {
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'global' does not exist on type '{}'.
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts ===
|
||||
interface I { global: string; }
|
||||
>I : Symbol(I, Decl(typeGuardsWithInstanceOf.ts, 0, 0))
|
||||
>global : Symbol(I.global, Decl(typeGuardsWithInstanceOf.ts, 0, 13))
|
||||
|
||||
var result: I;
|
||||
>result : Symbol(result, Decl(typeGuardsWithInstanceOf.ts, 1, 3))
|
||||
>I : Symbol(I, Decl(typeGuardsWithInstanceOf.ts, 0, 0))
|
||||
|
||||
var result2: I;
|
||||
>result2 : Symbol(result2, Decl(typeGuardsWithInstanceOf.ts, 2, 3))
|
||||
>I : Symbol(I, Decl(typeGuardsWithInstanceOf.ts, 0, 0))
|
||||
|
||||
if (!(result instanceof RegExp)) {
|
||||
>result : Symbol(result, Decl(typeGuardsWithInstanceOf.ts, 1, 3))
|
||||
>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
result = result2;
|
||||
>result : Symbol(result, Decl(typeGuardsWithInstanceOf.ts, 1, 3))
|
||||
>result2 : Symbol(result2, Decl(typeGuardsWithInstanceOf.ts, 2, 3))
|
||||
|
||||
} else if (!result.global) {
|
||||
>result.global : Symbol(I.global, Decl(typeGuardsWithInstanceOf.ts, 0, 13))
|
||||
>result : Symbol(result, Decl(typeGuardsWithInstanceOf.ts, 1, 3))
|
||||
>global : Symbol(I.global, Decl(typeGuardsWithInstanceOf.ts, 0, 13))
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts ===
|
||||
interface I { global: string; }
|
||||
>I : I
|
||||
>global : string
|
||||
|
||||
var result: I;
|
||||
>result : I
|
||||
>I : I
|
||||
|
||||
var result2: I;
|
||||
>result2 : I
|
||||
>I : I
|
||||
|
||||
if (!(result instanceof RegExp)) {
|
||||
>!(result instanceof RegExp) : boolean
|
||||
>(result instanceof RegExp) : boolean
|
||||
>result instanceof RegExp : boolean
|
||||
>result : I
|
||||
>RegExp : RegExpConstructor
|
||||
|
||||
result = result2;
|
||||
>result = result2 : I
|
||||
>result : I
|
||||
>result2 : I
|
||||
|
||||
} else if (!result.global) {
|
||||
>!result.global : boolean
|
||||
>result.global : string
|
||||
>result : I
|
||||
>global : string
|
||||
}
|
Loading…
Reference in a new issue