1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
=== tests/cases/compiler/narrowCommaOperatorNestedWithinLHS.ts ===
const otherValue = () => true;
>otherValue : Symbol(otherValue, Decl(narrowCommaOperatorNestedWithinLHS.ts, 0, 5))
const value: { inner: number | string } = null as any;
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
function isNumber(obj: any): obj is number {
>isNumber : Symbol(isNumber, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 54))
>obj : Symbol(obj, Decl(narrowCommaOperatorNestedWithinLHS.ts, 3, 18))
>obj : Symbol(obj, Decl(narrowCommaOperatorNestedWithinLHS.ts, 3, 18))
return true; // method implementation irrelevant
}
if (typeof (otherValue(), value).inner === 'number') {
>(otherValue(), value).inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>otherValue : Symbol(otherValue, Decl(narrowCommaOperatorNestedWithinLHS.ts, 0, 5))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
const a = value.inner; // number
>a : Symbol(a, Decl(narrowCommaOperatorNestedWithinLHS.ts, 8, 9))
>value.inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
const b: number = (otherValue(), value).inner; // string | number , but should be number
>b : Symbol(b, Decl(narrowCommaOperatorNestedWithinLHS.ts, 9, 9))
>(otherValue(), value).inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>otherValue : Symbol(otherValue, Decl(narrowCommaOperatorNestedWithinLHS.ts, 0, 5))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
}
if (isNumber((otherValue(), value).inner)) {
>isNumber : Symbol(isNumber, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 54))
>(otherValue(), value).inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>otherValue : Symbol(otherValue, Decl(narrowCommaOperatorNestedWithinLHS.ts, 0, 5))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
const a = value.inner; // number
>a : Symbol(a, Decl(narrowCommaOperatorNestedWithinLHS.ts, 13, 9))
>value.inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
const b: number = (otherValue(), value).inner; // string | number , but should be number
>b : Symbol(b, Decl(narrowCommaOperatorNestedWithinLHS.ts, 14, 9))
>(otherValue(), value).inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
>otherValue : Symbol(otherValue, Decl(narrowCommaOperatorNestedWithinLHS.ts, 0, 5))
>value : Symbol(value, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 5))
>inner : Symbol(inner, Decl(narrowCommaOperatorNestedWithinLHS.ts, 1, 14))
}
|