本文介绍了Angular 4,ng2-redux:找不到模块“redux-logger"的声明文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从 git clone https://github.com/angular/quickstart.git
和
npm i --save redux-logger redux ng2-redux
这里.../node_modules/redux-logger/src/index.js
有
export { defaults, createLogger, defaultLogger as logger };
错误:TS7016:找不到模块redux-logger"的声明文件.'.../node_modules/redux-logger/dist/redux-logger.js' 隐式具有 'any' 类型.
import { applyMiddleware, createStore } from 'redux';
import logger from 'redux-logger';
//import { createLogger } from 'redux-logger';
const store = createStore(
rootReducer,
applyMiddleware(logger)
);
//const store = createStore(
// rootReducer,
// applyMiddleware(createLogger())
//);
使用 createLogger() 时同样的错误
The same error when using createLogger()
如何解决这个问题?
谢谢.
推荐答案
您必须使用 typescript.为了导入任何 javascript 库/模块,您需要其相应的类型声明,这些声明通常包含在 绝对输入.
You must be using typescript. In order to import any javascript library/module, you need its corresponding type declarations which are generally included in DefinitelyTyped.
做:
npm i @types/redux-logger --save-dev
包在这里.然后你可以导入为:
The package is here.Then you can import as:
import { createLogger } from 'redux-logger';
这篇关于Angular 4,ng2-redux:找不到模块“redux-logger"的声明文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!