[英]Could not find a declaration file for module while importing a node module using ES6
I have setup loopback 4 and trying to write a new controller for my Braintree API payments. 我已经设置了环回4,并试图为我的Braintree API付款编写一个新的控制器。 I have installed the Braintree npm module and using
我已经安装了Braintree npm模块并使用
import {braintree} from 'braintree';
to import into a controller and use in an endpoint. 导入控制器并在端点中使用。 But it is throwing me following error:
但这使我产生以下错误:
*src/controllers/braintree.controller.ts:23:25 - error TS7016: Could not find a declaration file for module 'braintree'. '/home/oem/Learning/learn-loopback/my-todo-app/node_modules/braintree/index.js' implicitly has an 'any' type.
Try `npm install @types/braintree` if it exists or add a new declaration (.d.ts) file containing `declare module 'braintree';*`
When I try the es5 way of importing it is working fine. 当我尝试导入es5的方式时,它工作正常。
Not sure how to fix this. 不确定如何解决此问题。
The braintree type does not seem to exist yet. 脑树类型似乎还不存在。 So here you have 2 possibilities:
因此,这里有两种可能性:
import {braintree} from 'braintree';
import {braintree} from 'braintree';
替换import {braintree} from 'braintree';
with const braintree = require('braintree');
const braintree = require('braintree');
but you won't have access to all the typescript magic, so be careful when manipulating this library.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.