npm程序包包含类型,但获取TS7016:找不到声明文件

时间:2019-06-23 02:38:48

标签: typescript

我指的是确实有类型的npm软件包。

import { Api, ApiInterfaces, RpcInterfaces, JsonRpc } from 'eosjs';

但是在构建时会得到这个

src/index.ts(1,60): error TS7016: Could not find a declaration file for module 'eosjs'. '/XXXXX/node_modules/eosjs/dist/index.js' implicitly has an 'any' type.  
  Try `npm install @types/eosjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'eosjs';`

但是您是否可以看到npm软件包确实有键入内容

ls node_modules/eosjs/dist/index.* -1  
node_modules/eosjs/dist/index.d.ts  
node_modules/eosjs/dist/index.js  
node_modules/eosjs/dist/index.js.map  

你知道这是怎么回事吗?

0 个答案:

没有答案