Having the following:
tsconfig
{
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"jsx": "react",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"declaration": true,
"outDir": "lib",
"lib": ["es2015","dom"]
}
}
Note declaration : true
And .tsx file:
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%;
`;
When I run tsc on the terminal to compile I get:
error TS2339: Property 'div' does not exist on type 'typeof "/root/node_modules/styled-comp...'.
UPDATE
The error happens with both ways of importing styled-components
import styled from 'styled-components'
import * as styled from 'styled-components'