【发布时间】:2018-02-09 22:10:19
【问题描述】:
具备以下条件:
tsconfig
{
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"jsx": "react",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"declaration": true,
"outDir": "lib",
"lib": ["es2015","dom"]
}
}
注意声明:true
还有.tsx文件:
import * as styledComponents from "styled-components";
export const backColor = (props: MyProps) => props.theme.backColor;
export const Title = styledComponents.div`
text-align: center;
background-color:${backColor};
width: 100%;
`;
当我在终端上运行tsc 进行编译时,我得到:
错误 TS2339:类型 'typeof "/root/node_modules/styled-comp...' 上不存在属性 'div'。
更新
两种导入样式组件的方式都会发生错误
import styled from 'styled-components'
import * as styled from 'styled-components'
【问题讨论】:
标签: reactjs typescript jsx styled-components tsx