3
我正在嘗試在TypeScrpt中爲Mongoose ODM使用ES6 Promises。在Mongoose代碼中使用ES6 Promise
我有以下線
mongoose.Promise = Promise;
這給我下面的錯誤:
error TS2322: Type 'PromiseConstructor' is not assignable to type 'typeof Promise'.
Type 'Promise<any>' is not assignable to type 'Promise<any>'.
Property 'end' is missing in type 'Promise<any>'.
我正在按照Mongoose網站上的說明進行操作,http://mongoosejs.com/docs/promises.html IT好像打字稿編譯器對某些東西不滿意。 –
請記住,Mongoose可能需要Promise規範的更全面的實現,而不是原生的'Promise'。香草的實施是非常基礎的。 – Andrew
'require('mongoose')。Promise = Promise;'在節點'v5.3.0'下適合我,你的節點版本是什麼? – zangw