Last active
December 10, 2024 12:30
-
-
Save mistakster/b4dfa8866cb033d20002f8cce7a4617e to your computer and use it in GitHub Desktop.
A case for interviewing a TypeScript developer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The objective is to properly implement `ControlProps`. | |
const Control = (props: ControlProps) => { | |
const { variant, ...rest } = props; | |
if (variant === "button") { | |
return ( | |
<button {...rest} /> | |
); | |
} if (variant === "link") { | |
return ( | |
<a {...rest} /> | |
); | |
} | |
return null; | |
} | |
const Panel = () => ( | |
<> | |
<Control variant="button" type="button" onClick={() => {}}> | |
I am a button | |
</Control> | |
<Control variant="link" href="#"> | |
I am an anchor | |
</Control> | |
</> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment