I can't find a way to make Emotion theming work with TypeScript.
import React from "react";
import { ThemeProvider } from "emotion-theming";
import styled from "@emotion/styled";
const theme = {
colors: {
gray: "#ccc",
},
};
const MyComponent = styled.div((props) => ({
color: props.theme.colors.gray,
}));
const App = () => (
<ThemeProvider theme={theme}>
<MyComponent />
</ThemeProvider>
);
export default App;
The docs says: "By default, props.theme has an any type annotation and works without any errors". But I have one on props.theme.colors.gray
: Property 'colors' does not exist on type 'object'.ts(2339)
Am I missing something here?