I have an object
export const TOOLTIP_PLACEMENTS = Object.freeze({
TOP: 'top',
BOTTOM: 'bottom',
LEFT: 'left',
RIGHT: 'right',
});
And a component:
type Props = {
text?: string;
children: React.ReactNode;
placement?: keyof typeof TOOLTIP_PLACEMENTS;
};
const Tooltip = ({
text,
children,
placement = TOOLTIP_PLACEMENTS.BOTTOM,
}: Props) => (
<StyleTippy
content={<TitleContainer>{text}</TitleContainer>}
placement={placement}
arrow={true}
>
{children}
</StyleTippy>
);
However, Typescript is complaining that I am sending it a string literal
src/components/Tooltip.tsx:41:3 - error TS2322: Type 'string' is not assignable to type '"TOP" | "BOTTOM" | "LEFT" | "RIGHT"'.
41 placement = TOOLTIP_PLACEMENTS.BOTTOM,
~~~~~~~~~
How would I fix this?