问题描述
我找不到让TypeScript与Emotion主题配合使用的方法。
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;
文档说:“默认情况下,props.theme具有任何类型的注释,并且可以正常运行”。但是我在props.theme.colors.gray
上有一个:类型“ object”上不存在属性“ colors”。ts(2339)
我在这里想念东西吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)