I am running into an issue where typescript will not allow me to name a property type
This fails:
import "./styles.css";
import styled from "styled-components";
enum BUTTON_TYPES {
BUTTON = "button",
SUBMIT = "submit"
}
interface ButtonProps {
type: BUTTON_TYPES; // <------------------------ this
}
const Button = styled.button<ButtonProps>``;
export default function App() {
return (
<div className="App">
<Button type={BUTTON_TYPES.BUTTON}>hey</Button>
</div>
);
}
However, if I rename type to foobar, it works perfectly fine
import "./styles.css";
import styled from "styled-components";
enum BUTTON_TYPES {
BUTTON = "button",
SUBMIT = "submit"
}
interface ButtonProps {
foobar: BUTTON_TYPES; // <------------------------ this
}
const Button = styled.button<ButtonProps>``;
export default function App() {
return (
<div className="App">
<Button foobar={BUTTON_TYPES.BUTTON}>hey</Button>
</div>
);
}
https://codesandbox.io/s/charming-borg-hl2x6?file=/src/App.tsx