Definitelytyped: [styled-components] Property 'View' does not exist on type 'ThemedBaseStyledInterface<any>'. Did you mean 'view'?

Created on 5 Oct 2018  路  4Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

Authors: @Igorbek @Igmat
typescript: ^3.0.1
styled-components: 4.0.0-beta.10 and also tried 3.4.9
@types/styled-components: 3.0.1

If try to do:
const A = styled.View I get the error:

Property 'View' does not exist on type 'ThemedBaseStyledInterface<any>'. Did you mean 'view'

Am I doing something wrong?

Most helpful comment

Here is your answer:
change import styled from 'styled-components'; into import styled from 'styled-components/native';

All 4 comments

Here is your answer:
change import styled from 'styled-components'; into import styled from 'styled-components/native';

@gitsad thanks! A friend told me the same thing some days ago, I think it should be better documented in the styled-components docs

This issue needs to be reopened.

When I'm importing styled-components like: import styled from "styled-components/native"
TypeScript throws an error: TS7016: Could not find a declaration file for module 'styled-components/native'. '[project_path]/node_modules/styled-components/native/dist/styled-components.native.cjs.js' implicitly has an 'any' type.

Package versions:
typescript: 3.1.1
styled-component: 4.0.0-beta.11.3
@types/styled-components: 4.0.1 also tried 3.0.2

Beside that styled-components/native is deprecated from version 3 or higher so importing from it shouldn't be a solution.

@dawidk92 Using @types/styled-component: 3.0.2 and styled-component: 3.4.9, I am able to use when importing from styled-components/native. I think the 4.0.0 beta still does not have types.

Was this page helpful?
0 / 5 - 0 ratings