React and TypeScript

Bounded polymorphic props

A discriminated union links a rendering choice to allowed props.

Formal Syntax & Structure

react syntaxreact
{as:"a";href:string}|{as:"button";href?:never}

Working Example

Example Snippetreact
{as:"a";href:string}|{as:"button";href?:never}
React Reference