如何在没有 DefinitelyTyped 的情况下停止对函数的警告?
How to stop warnings for functions without DefinitelyTyped?
如果某些函数或库没有DefinitelyTyped,我知道这两种方法可以停止警告。
interface Navigator {
getUserMedia: any
}
declare let RTCIceCandidate: any;
但是现在,这个第 3 部分库 Collection2 是这样使用的:
let ProductSchema = {};
let Products = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
它给我一个警告:
Property 'attachSchema' does not exist on type 'Collection'.
下面的方法试过了,还是不行
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
。如何解决这个问题?谢谢
感谢阿米德的帮助。所以方法是:
(<any>Meteor.users).attachSchema(UserSchema);
如果某些函数或库没有DefinitelyTyped,我知道这两种方法可以停止警告。
interface Navigator {
getUserMedia: any
}
declare let RTCIceCandidate: any;
但是现在,这个第 3 部分库 Collection2 是这样使用的:
let ProductSchema = {};
let Products = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
它给我一个警告:
Property 'attachSchema' does not exist on type 'Collection'.
下面的方法试过了,还是不行
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
。如何解决这个问题?谢谢
感谢阿米德的帮助。所以方法是:
(<any>Meteor.users).attachSchema(UserSchema);