मैं निम्न त्रुटि हो रही है नहीं मिल सकता है:टाइपप्रति redux
node_modules/@types/react-redux/index.d.ts(8,24): error TS2307: Cannot find module 'redux'.
स्थापित करने के बाद भी दोनों react-redux
और redux
(package.json
):
"dependencies": {
"react": "15.4.2",
"react-native": "0.42.3",
"react-redux": "^5.0.3",
"redux": "^3.6.0"
},
"devDependencies": {
"@types/react": "^15.0.18",
"@types/react-native": "^0.42.9",
"@types/react-redux": "^4.4.38",
"@types/redux": "^3.6.0",
"babel-jest": "19.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "19.0.2",
"react-test-renderer": "15.4.2",
"tslint": "^4.5.1",
"typescript": "^2.2.1"
},
@types/redux
में README.md
फ़ाइल का कहना है:
This is a stub types definition for Redux (https://github.com/reactjs/redux).
Redux provides its own type definitions, so you don't need @types/redux installed!
लेकिन संयुक्त राष्ट्र @types/redux
पैकेज स्थापित करने से कोई फर्क नहीं पड़ता।
कोई भी विचार?
अद्यतन
मैंने सोचा था कि @types/redux
निर्देशिका (केवल export * from ../../redux/index
युक्त) के लिए एक index.d.ts
जोड़कर, यह समस्या है, लेकिन कोई खुशी का समाधान होगा।
यहाँ मेरी tsconfig.json
है:
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"jsx": "react",
"outDir": "build",
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"allowJs": true,
"sourceMap": true
},
"filesGlob": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"__tests__",
"index.android.js",
"index.ios.js",
"build",
"node_modules"
],
"compileOnSave": false
}
और मैं निश्चित रूप से node_modules
से @types/redux
निर्देशिका नष्ट कर दिया। मैं (जाहिर है) टाइपस्क्रिप्ट 2.2.1 चला रहा हूँ।
अद्यतन 2
कोड redux
का उपयोग कर:
import { combineReducers } from "redux"
export default combineReducers({})
ध्यान दें कि "redux"
के बाद अर्धविराम जोड़ने में मदद नहीं करता।
हाँ, यह बिना '@ प्रकार/redux' काम करना चाहिए। दरअसल, मुझे लगता है कि मुझे समस्याएं थीं, जब मेरे पास '@ प्रकार/redux' स्थापित था ... क्या आप कोड का एक टुकड़ा प्रदान कर सकते हैं जिसमें आप रेडक्स आयात कर रहे हैं? –
बस सुनिश्चित करने के लिए, यहां अपने tsconfig.json को भी डालें। –
'आयात' createStore, Store, Reducer} 'redux' से यह काम करता है यह टाइपस्क्रिप्ट 2.3.0-dev.20170320 –