Skip to content Skip to sidebar Skip to footer

Node.js With Typescript Require And .d.ts Files

I want to create an server side script, for this I require 'Q', so I include the q.d.ts file. And I use this to import q: var Q = require('q'); Now I recive this error: Duplicate

Solution 1:

Duplicate identifier 'Q'

In the absence of an import or an export statement at the root of your file: Your file as well as any other such file passed to the TypeScript compiler is considered a part of the global namespace. So the variable Q is conflicting with the one declared in q.d.ts.

Fix

import Q, don't just require it :

import Q = require("q");

More about External modules : https://www.youtube.com/watch?v=KDrWLMUY0R0


Post a Comment for "Node.js With Typescript Require And .d.ts Files"