【发布时间】:2016-06-28 03:34:33
【问题描述】:
如果某些函数或库没有DefinitelyTyped,我知道这两种停止警告的方法。
interface Navigator {
getUserMedia: any
}
declare let RTCIceCandidate: any;
但是现在,这个第 3 部分库 Collection2 是这样使用的:
let ProductSchema = {};
let Products = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
它给了我一个警告:
类型“Collection”上不存在属性“attachSchema”。
我尝试了下面的方法,但它不起作用。
interface Collection {
attachSchema: any
}
如何停止此警告?谢谢
编辑:
Eric 添加any 的方式解决了这个问题。
let Products:any = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
但现在新的麻烦来了:
let UserSchema = {};
Meteor.users.attachSchema(UserSchema);
由于Meteor.users是内置的,所以没有地方添加any。如何解决这个问题?谢谢
【问题讨论】:
-
错误是完全正确的。 These 是 javascript 中字符串可用的所有方法。
-
@EricMartinez 谢谢,我实际上想以字符串为例,所以现在我更具体地更改了我的问题
-
你试过
let Products: any = new Mongo.Collection('products');吗? (注意any) -
@EricMartinez 哇,这是个好技巧,哈!谢谢!
-
像这样:(
Meteor.users).attachSchema(UserSchema);
标签: meteor typescript angular meteor-collection2 angular2-meteor