1//// [booleanLiteralsContextuallyTypedFromUnion.tsx] 2interface A { isIt: true; text: string; } 3interface B { isIt: false; value: number; } 4type C = A | B; 5const isIt = Math.random() > 0.5; 6const c: C = isIt ? { isIt, text: 'hey' } : { isIt, value: 123 }; 7const cc: C = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; 8 9type ComponentProps = 10 | { 11 optionalBool: true; 12 mandatoryFn: () => void; 13 } 14 | { 15 optionalBool: false; 16 }; 17 18let Funk = (_props: ComponentProps) => <div>Hello</div>; 19 20let Fail1 = () => <Funk mandatoryFn={() => { }} optionalBool={true} /> 21let Fail2 = () => <Funk mandatoryFn={() => { }} optionalBool={true as true} /> 22let True = true as true; 23let Fail3 = () => <Funk mandatoryFn={() => { }} optionalBool={True} /> 24let attrs2 = { optionalBool: true as true, mandatoryFn: () => { } } 25let Success = () => <Funk {...attrs2} /> 26 27//// [booleanLiteralsContextuallyTypedFromUnion.jsx] 28"use strict"; 29var isIt = Math.random() > 0.5; 30var c = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; 31var cc = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; 32var Funk = function (_props) { return <div>Hello</div>; }; 33var Fail1 = function () { return <Funk mandatoryFn={function () { }} optionalBool={true}/>; }; 34var Fail2 = function () { return <Funk mandatoryFn={function () { }} optionalBool={true}/>; }; 35var True = true; 36var Fail3 = function () { return <Funk mandatoryFn={function () { }} optionalBool={True}/>; }; 37var attrs2 = { optionalBool: true, mandatoryFn: function () { } }; 38var Success = function () { return <Funk {...attrs2}/>; }; 39