3

I've got a NodeJS app (built in Visual Studio) which uses TypeScript, and MongoDB.

I've written a small library which wraps the MongoDB driver in some TypeScript classes and just today it started acting up.

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

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

it build briefly, before begining to complain about "Duplicate identifier"s, and lots 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 that out, and everything is briefly ok, until I start seeing issues reported around this line:

import mongodbNS = require('mongodb');

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

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

I can muddle through by adding a removing things and taking advantage of the brief window of compilability which opens up - but clearly this is not the way.

What is?

2
  • an example of a duplicate identifier error message would be great Commented Sep 19, 2014 at 1:28
  • I'm using Node Tools for VS 2013, and they all come from node.d.ts. I've added some examples above. Commented Sep 19, 2014 at 1:33

1 Answer 1

5

and they all come from node.d.ts

This is happening because you have two versions of node.d.ts (i.e. different files on disk) in your project.

Sign up to request clarification or add additional context in comments.

10 Comments

That occurred to me as well, so I did a search and of course there are two. But they are both part of other d.ts files: socket.io.d.ts, and mongodb.d.ts, which are both used in the solution. So, which one do I get rid of?
@Michael the older one. They should be compatible.
And then fix the reference in the one that was referencing the older version
They are in two different projects in the solution, each one referencing a project-local version of node.d.ts, each of which says "// Type definitions for Node.js v0.10.1" - so which is older? This seems like a likely cause of the problem, but something isn't adding up.
I was able to remove the reference to node.d.ts in the mongodb.d.ts file (it doesn't appear to be necessary) and that seems to have made the problem go away.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.