Assert the variable as a React.ElementType Example: const Component = (isFoo ? FooComponent : BarComponent) as React.ElementType