Missing declaration file
harrington101 opened this issue · comments
I am receiving an error when I try to import this that says "Could not find a declaration file for module 'react-native-responsive-dimensions". ' implicitly has an 'any' type. Try 'npm install @types/react-native-responsive-dimensions' if it exists or add a new declaration (.d.ts) file containing 'declare module 'react-native-responsive-dimensions';'
@harrington101 are you using typescript? Responsive dimensions is created without typescript in plain javascript...
No typescript.
Can you share your package.json file...
"name": "MyReactNativeApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/async-storage": "^1.6.2",
"expo": "^35.0.0",
"expo-cli": "^2.21.2",
"hammerjs": "^2.0.8",
"hoist-non-react-statics": "^3.3.0",
"msal": "^1.1.3",
"native-base": "^2.13.8",
"react": "16.9.0",
"react-azure-adb2c": "^0.2.0",
"react-native": "0.61.1",
"react-native-elements": "^1.2.1",
"react-native-gesture-handler": "^1.4.1",
"react-native-orientation": "^3.1.3",
"react-native-ratings": "^6.5.0",
"react-native-reanimated": "^1.2.0",
"react-native-responsive-dimensions": "^3.0.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-native-shadow": "^1.2.2",
"react-native-svg": "^9.9.5",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^7.4.0",
"react-navigation": "^4.0.9",
"react-navigation-drawer": "^2.2.2",
"react-navigation-stack": "^1.9.0"
},
"devDependencies": {
"@babel/core": "7.6.2",
"@babel/runtime": "7.6.2",
"@react-native-community/eslint-config": "0.0.3",
"babel-jest": "24.9.0",
"eslint": "6.4.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}```
Here is my SiteStyle.js file:
import { StyleSheet } from 'react-native'
import {
responsiveHeight,
responsiveWidth,
responsiveFontSize
} from "react-native-responsive-dimensions";
export default StyleSheet.create({
navBar: {
backgroundColor: '#fdccfd'
},
navDrawerHeader: {...
In VS Code I get the error:
"Could not find a declaration file for module 'react-native-responsive-dimensions'.
'c:/Users/..../node_modules/react-native-responsive-dimensions/src/index.js' implicitly has an 'any' type.
Try 'npm install @@types/react-native-responsive-dimensions' if it exists or add a new declaration (.d.ts) file containingdeclare module 'react-native-responsive-dimensions';
@harrington101 the above issue only occurs in a typescript environment. I couldn't understand why VS Code is type-checking your project. Please add the import statement to the ignore list as given in this answer https://stackoverflow.com/a/56877787/5597641 and let me know if the error is gone...
Version 3.1.0 will have full typescript support & this issue will be fixed