// @jsx: react // @strict: true // @esModuleInterop: true /// import React from 'react'; interface PS { multi: false value: string | undefined onChange: (selection: string | undefined) => void } interface PM { multi: true value: string[] onChange: (selection: string[]) => void } export function ComponentWithUnion(props: PM | PS) { return

; } // Usage with React tsx export function HereIsTheError() { return ( console.log(val)} // <- this throws an error /> ); } // Usage with pure TypeScript ComponentWithUnion({ multi: false, value: 's', onChange: val => console.log(val) // <- this works fine });