Using with React-Native and TypeScript, import implicity has 'any' type
See original GitHub issueWhen using styled-components/native importing default has an implicity any, causing IDE showing the following error:
Error:(2, 20) TS7016: Could not find a declaration file for module 'styled-components/native'. '/Users/<user>/Development/<project>/node_modules/styled-components/native/dist/styled-components.native.cjs.js' implicitly has an 'any' type.
Environment
System:
- OS: macOS 10.14.2
- CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz
- Memory: 290.28 MB / 16.00 GB
- Shell: 3.2.57 - /bin/bash
Binaries:
- Node: 10.14.1 - /usr/local/bin/node
- Yarn: 1.12.3 - /usr/local/bin/yarn
- npm: 6.4.1 - /usr/local/bin/npm
npmPackages:
- styled-components: ^4.1.3 => 4.1.3
Reproduction
just import styled-components/native
Steps to reproduce
insert import styled from 'styled-components/native';
Expected Behavior
Don’t show TS7016 error.
Actual Behavior
Showing the following error: Error:(2, 20) TS7016: Could not find a declaration file for module ‘styled-components/native’. ‘/Users/<user>/Development/<Project>/node_modules/styled-components/native/dist/styled-components.native.cjs.js’ implicitly has an ‘any’ type.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Could not find a declaration file for module 'module-name ...
'/path/to/node_modules/@ts-stack/di/dist/index.js' implicitly has an 'any' type. And yet, if I import as follows, then everything works: import ...
Read more >How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
Read more >Could not find declaration file for module 'X' Error | bobbyhadz
The error "Could not find declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve the...
Read more >TypeScript TS7016 Could not Find Declaration Implicitly has ...
Allow for Implicit Any Imports (tsconfig.json) · Use JavaScript Libraries with TS Support · Ensure the File Extension is TS not JS ·...
Read more >TypeScript errors and how to fix them
TS1192. error TS1192: Module ' json5 ' has no default export. ... Import Node.js type definitions first in order to use Node.js core...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Add types for react-native:
❯ yarn add @types/styled-components-react-native -D
import styled from ‘styled-components/native’;
The Error was like this: Error:(2, 20) TS7016: Could not find a declaration file for module ‘styled-components/native’. ‘/Users/<user>/Development/<project>/node_modules/styled-components/native/dist/styled-components.native.cjs.js’ implicitly has an ‘any’ type.
Solution: All you have to do is edit your TypeScript Config file (tsconfig.json) and add a new key-value pair as “noImplicitAny”: false