Skip to content

Instantly share code, notes, and snippets.

@mathieu-anderson
Created September 1, 2019 13:14
Show Gist options
  • Save mathieu-anderson/79a058aebc52d92b87a97bccdb8d9b10 to your computer and use it in GitHub Desktop.
Save mathieu-anderson/79a058aebc52d92b87a97bccdb8d9b10 to your computer and use it in GitHub Desktop.
Defining an interface
// Defining an interface
type InputValue = string | number;
type Label = string;
interface InputProps {
value: InputValue;
label: Label;
}
function InterfaceTsInput(props: InputProps) {
const { value, label } = props;
return (
<div className="container">
<div className="label">{label}</div>
<div className="typeof">
Type: <b>{typeof value}</b>
</div>
<input value={value} />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment