Tag: 定义

sendgrid的打字稿定义

我正在尝试编写一个使用sendgrid的打字稿应用程序,但与其他定义不同,我从打字input中find了typings install sendgrid –ambient一些typings install sendgrid –ambient引起了一些问题: 我能够像这样实例化客户端: import * as sendgrid from 'sendgrid'; import Email = Sendgrid.Email; import Instance = Sendgrid.Instance; … private client: Instance; … this.client = sendgrid(user, key); 然后在代码的后面,我试图发送一封电子邮件,这就是为什么ts迫使我导入电子邮件接口的第一位。 var email = new Email(); … this.client.send(email, (err, data) => { if (err) { throw err; } }); tslint不会抛出任何错误,但是当我构build和运行程序(或者只是我的testing),我得到这个: 摩卡爆炸了! ReferenceError:Sendgrid没有在Object中定义。 (/Users/chrismatic/codingprojects/weview/weview-node/build/server/components/mail/clients/sendgrid.js:4:13) 有没有人有一个工作实施展示,还是我必须写我自己的界面? […]

Typescript – 为什么“方法”属性不存在mongoose?

我在nodejs中编写打字稿。 当我编码mongoose模式时,Typescript编译器如下所示: app/models/user.schema.ts(15,12): error TS2339: Property 'methods' does not exis t on type 'Schema'. 我觉得很奇怪 我已经参考指南的 Instance methods部分中的文档。 它提到如下: // assign a function to the "methods" object of our animalSchema animalSchema.methods.findSimilarTypes = function (cb) { return this.model('Animal').find({ type: this.type }, cb); } 我认为methods是一个可用的属性或API。 但是对于打字稿,这是错误的。 接下来,我查找定义。 我find方法(名称:string,FN:function)和方法(方法:对象)这些属性,但它没有methods 。 总之,你不回答为什么mongoose定义的作者没有定义财产。 我需要一个答案mongoose的methods实际上是否可用?