Javascript – Using Nodejs with Typescript


I would like to use Nodejs in my typescript project and downloaded node.d.ts from

But VisualStudio finds a lot of errors in the .d.ts file. They're all basically the same:

Error 2 exported interface 'Server' extends interface from private
module 'events' C:\Users\lhk\Desktop\typescript-game\strategy
go\node\node-0.8.d.ts 236 37 node-0.8.d.ts

All the error messages complain that a private interface is extended.

I searched SO and found this question:
nodejs require inside TypeScript file

One of the comments gives the advice to download node.d.ts from the Microsoft samples. I browsed the internet, found this article and downloaded the second version of node.d.ts , with the exact same result.

Where do I find a proper definitions file for nodejs and Typescript ?

Best Solution

For the 0.8.1-1 version of TypeScript, use the latest node.d.ts file from this github project:

I was getting the same exported interface errors until I pulled the latest definition files from there.