Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (4k points)

'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?

1 Answer

0 votes
by (8.7k points)

You are encountering this in MongoDB because you have two versions of node.d.ts (different files on disk) in your project.

Related questions

0 votes
1 answer
asked Mar 1, 2021 in Web Technology by adhiraj (4k points)
0 votes
1 answer

Browse Categories

...