|
| 1 | +=== tests/cases/compiler/booleanLiteralsContextuallyTypedFromUnion.tsx === |
| 2 | +interface A { isIt: true; text: string; } |
| 3 | +>A : Symbol(A, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 0)) |
| 4 | +>isIt : Symbol(A.isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 13)) |
| 5 | +>text : Symbol(A.text, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 25)) |
| 6 | + |
| 7 | +interface B { isIt: false; value: number; } |
| 8 | +>B : Symbol(B, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 41)) |
| 9 | +>isIt : Symbol(B.isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 1, 13)) |
| 10 | +>value : Symbol(B.value, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 1, 26)) |
| 11 | + |
| 12 | +type C = A | B; |
| 13 | +>C : Symbol(C, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 1, 43)) |
| 14 | +>A : Symbol(A, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 0)) |
| 15 | +>B : Symbol(B, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 0, 41)) |
| 16 | + |
| 17 | +const isIt = Math.random() > 0.5; |
| 18 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 3, 5)) |
| 19 | +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) |
| 20 | +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 21 | +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) |
| 22 | + |
| 23 | +const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; |
| 24 | +>c : Symbol(c, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 4, 5)) |
| 25 | +>C : Symbol(C, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 1, 43)) |
| 26 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 3, 5)) |
| 27 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 4, 21)) |
| 28 | +>text : Symbol(text, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 4, 27)) |
| 29 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 4, 45)) |
| 30 | +>value : Symbol(value, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 4, 51)) |
| 31 | + |
| 32 | +const cc: C = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; |
| 33 | +>cc : Symbol(cc, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 5)) |
| 34 | +>C : Symbol(C, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 1, 43)) |
| 35 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 3, 5)) |
| 36 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 22)) |
| 37 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 3, 5)) |
| 38 | +>text : Symbol(text, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 34)) |
| 39 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 52)) |
| 40 | +>isIt : Symbol(isIt, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 3, 5)) |
| 41 | +>value : Symbol(value, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 64)) |
| 42 | + |
| 43 | +type ComponentProps = |
| 44 | +>ComponentProps : Symbol(ComponentProps, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 78)) |
| 45 | + |
| 46 | + | { |
| 47 | + optionalBool: true; |
| 48 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 8, 7)) |
| 49 | + |
| 50 | + mandatoryFn: () => void; |
| 51 | +>mandatoryFn : Symbol(mandatoryFn, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 9, 27)) |
| 52 | + } |
| 53 | + | { |
| 54 | + optionalBool: false; |
| 55 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 12, 7)) |
| 56 | + |
| 57 | + }; |
| 58 | + |
| 59 | +let Funk = (_props: ComponentProps) => <div>Hello</div>; |
| 60 | +>Funk : Symbol(Funk, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 3)) |
| 61 | +>_props : Symbol(_props, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 12)) |
| 62 | +>ComponentProps : Symbol(ComponentProps, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 5, 78)) |
| 63 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 64 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 65 | + |
| 66 | +let Fail1 = () => <Funk mandatoryFn={() => { }} optionalBool={true} /> |
| 67 | +>Fail1 : Symbol(Fail1, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 18, 3)) |
| 68 | +>Funk : Symbol(Funk, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 3)) |
| 69 | +>mandatoryFn : Symbol(mandatoryFn, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 18, 23)) |
| 70 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 18, 47)) |
| 71 | + |
| 72 | +let Fail2 = () => <Funk mandatoryFn={() => { }} optionalBool={true as true} /> |
| 73 | +>Fail2 : Symbol(Fail2, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 19, 3)) |
| 74 | +>Funk : Symbol(Funk, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 3)) |
| 75 | +>mandatoryFn : Symbol(mandatoryFn, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 19, 23)) |
| 76 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 19, 47)) |
| 77 | + |
| 78 | +let True = true as true; |
| 79 | +>True : Symbol(True, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 20, 3)) |
| 80 | + |
| 81 | +let Fail3 = () => <Funk mandatoryFn={() => { }} optionalBool={True} /> |
| 82 | +>Fail3 : Symbol(Fail3, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 21, 3)) |
| 83 | +>Funk : Symbol(Funk, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 3)) |
| 84 | +>mandatoryFn : Symbol(mandatoryFn, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 21, 23)) |
| 85 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 21, 47)) |
| 86 | +>True : Symbol(True, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 20, 3)) |
| 87 | + |
| 88 | +let attrs2 = { optionalBool: true as true, mandatoryFn: () => { } } |
| 89 | +>attrs2 : Symbol(attrs2, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 22, 3)) |
| 90 | +>optionalBool : Symbol(optionalBool, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 22, 14)) |
| 91 | +>mandatoryFn : Symbol(mandatoryFn, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 22, 42)) |
| 92 | + |
| 93 | +let Success = () => <Funk {...attrs2} /> |
| 94 | +>Success : Symbol(Success, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 23, 3)) |
| 95 | +>Funk : Symbol(Funk, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 16, 3)) |
| 96 | +>attrs2 : Symbol(attrs2, Decl(booleanLiteralsContextuallyTypedFromUnion.tsx, 22, 3)) |
| 97 | + |
0 commit comments