TypeScript, MongoDB, and Reference Questions

I have a NodeJS app (built in Visual Studio) that uses TypeScript and MongoDB.

I wrote a small library that wraps the MongoDB driver in some TypeScript classes and it just started working today.

If I include this line at the top of one of my library files:

/// <reference path='./_scripts/typings/mongodb/mongodb.d.ts' />

      

it builds up briefly before starting to complain about "Duplicate ID" and many of them, for example:

Error   6   Type name 'Transform' in extends clause does not reference constructor function for '"stream".Transform'.
Error   7   Type name 'events.EventEmitter' in extends clause does not reference constructor function for 'events.EventEmitter'.
Error   8   Duplicate identifier 'errno'.
Error   9   Duplicate identifier 'code'.
Error   10  Duplicate identifier 'path'.

      

So I take this and it is ok until I start seeing the problems described in this line:

import mongodbNS = require('mongodb');

      

If I were to remove this line, I would see errors with things like:

public Connect: () => Promise<mongodbNS.Db>;

      

I might get confused by adding the removal of things and taking advantage of the compilation shortcut dropdown, but this is clearly not the case.

What?

+3


source to share


1 answer


and they all come from node.d.ts



This is because there are two versions in your project node.d.ts

(i.e. different files on disk).

+5


source







All Articles