2015-09-16 19 views
0

我正在使用包meteortypescript:compilermeteortypescript:typescript-libs。我想查詢一個集合了這樣的記錄:爲什麼TypeScript不讓我查詢Meteor集合?

MyCollection.findOne({email: '[email protected]', username: 'bob'}); 

而且我得到這個錯誤:

error TS2345: Argument of type '{ email: string; username: string; }' 
is not assignable to parameter of type 'Selector'. 

這是沒有意義的,因爲我可以看到該類型Selector在我用於流星的.d.ts文件定義爲interface Selector extends Object {},這應該不會產生問題。任何指針?

+0

你是如何初始化你的收藏?例如:_Base.Collections.Channels = new Mongo.Collection (「channels」); _ – MichelH

+1

看起來像你使用的是明確的。你需要更新你的'meteor.d.ts'到最新的一個。請參閱[此更新](https://github.com/DanielRosenwasser/DefinitelyTyped/commit/b0c077fdd39f2b901677a5d58155f516f66f88d1)。 –

+0

謝謝傑西。事實證明,更新到'meteortypescript:typescript-libs'修復這顯然還沒有出去,所以我手動做到了,現在它的工作。 – jpadvo

回答

1

聯合interface Selector extends Object {}Argument of type '{ email: string; username: string; }' is not assignable to parameter of type 'Selector'.讓我覺得你有一個freshness又名strict object checking問題。這裏是一個簡化的例子:

interface Selector extends Object {} 

function foo(arg:Selector){} 
foo({ email: '[email protected]', username: 'asdf' }); // same error you are getting 
相關問題