-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package installed from npm still has Q in d.ts file #63
Comments
I think you're missing the typings for Q. |
Here's a project that we wrote that uses vsts-node-api https://github.com/Microsoft/tfsgit-pr-injector/blob/master/typings.json |
Thanks! It works perfectly. Can you please give me some hints for the reason? I am new to NodeJS and TypeScript. |
Sure. Typescript is a superset of javascript, and many libraries are still in pure javascript. So typescript came up with the concept of typings - a way to wrap existing js libraries in a typescript interface. Have a look at q.d.ts from the typings directory for an example - it's quite human readable. You'll note that you don't need typings for vsts-node-api, because it's already written in typescript. So now there are a few repositories of "typings", communities making sure old javascript libs can easily be used in typescript projects. Check out https://github.com/typings/typings for how to easily pull them in your nodejs + typescript proj. To get back to your error - although you had installed the q module, typescript could not use Q.Promise because it's missing a typings file that links the ts interface for the underlying js logic. |
Hi,
I am now writing an tfs web application. When I compile my application, tsc complains:
node_modules/vso-node-api/FileContainerApi.d.ts(1,20): error TS2307: Cannot find module 'q'. node_modules/vso-node-api/VsoClient.d.ts(1,20): error TS2307: Cannot find module 'q'.
In FileContainerApi.d.ts:
import Q = require('q');
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
import FileContainerApiBase = require("./FileContainerApiBase");
...
If I remove the import and replace Q.Promise with Promise, compilation is good.
Here are my question:
Is it safe for me to remove them?
Do I need any special setting for tsconfig? Current I have "target": "es6".
Thanks!
The text was updated successfully, but these errors were encountered: