otrzymuję następujący błąd:Maszynopis nie może znaleźć Redux
node_modules/@types/react-redux/index.d.ts(8,24): error TS2307: Cannot find module 'redux'.
pomimo zainstalowany zarówno react-redux
i 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"
},
Plik w @types/redux
README.md
mówi:
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!
ale un instalacja pakietu @types/redux
nie ma znaczenia.
Wszelkie pomysły?
UPDATE
Pomyślałem, że dodając index.d.ts
do katalogu @types/redux
(zawierającego tylko export * from ../../redux/index
), to rozwiąże problem, ale nie radość.
Oto mój 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
}
i zdecydowanie usunięty katalog @types/redux
z node_modules
. Jestem (oczywiście) działający TypeScript 2.2.1.
UPDATE 2
Code używając redux
:
import { combineReducers } from "redux"
export default combineReducers({})
Pamiętaj, że dodając średnik po "redux"
nie pomaga.
Tak, to powinno działać bez '@ rodzai/redux'. Właściwie, wydaje mi się, że miałem problemy, kiedy miałem zainstalowane '@ types/redux' ... Czy możesz podać kawałek kodu, w którym importujesz redux? –
Dla pewności, umieść tutaj także swój tsconfig.json. –
'import {createStore, Store, Reducer} z 'redux'' to działa dobrze w maszynopisie 2.3.0-dev.20170320 –