Thursday, 1 June 2017

How to get type information for Mongodb's emit function for Map-Reduce

I'm using TypeScript on a node.js application. I was just trying to setup a map-reduce call but I get the error:

Cannot find name 'emit'.

...anywhere I try to use the emit function in the map phase. I've got @types/mongoose and @types/mongodb installed, and can use type information from those files but there doesn't seem to be a definition for 'emit'. (I've got aggregate working in the same file along with various queries so in general things are working fine - I'm using mongoose if that makes a difference).

Note that I'm just asking for the type info to get rid of the red underlines in my IDE.

I have even added the following, and while the references work, it doesn't solve the problem:

///<reference path="../../../node_modules/@types/mongodb/index.d.ts" />
///<reference path="../../../node_modules/@types/mongoose/index.d.ts" />

Anyone have the emit function for mogodb map-reduce typed correctly in TypeScript?



via WillyC

No comments:

Post a Comment