简体   繁体   中英

Typescript declaration file for mongoose

Is there a typescript declaration file for mongoose? I've looked at Boris Yankov's Definitely Typed repo, but there does not seem to be one. Anyone know where I can get a good d.ts file for the mongoose library?

Kind regards as always.

I found a github project here . It has the mongoose typescript definitions in there.

Just an update on this. Now you should use typings to import your types definitions inside your application.

Use npm and install it globally:

$sudo npm install -g typings

to install the mongoose package:

$ typings install mongoose

More info about typings: https://www.npmjs.com/package/typings

Tutorial on how to setup mongoose with typings in typescript project: http://www.vandiest.biz/?p=3931

It is tempting to say that if it isn't on Definitely Typed it probably doesn't exist.

Of course, it was only a matter of time before it was added: Definitely Typed definition for Mongoose .

You can get all of the Definitely Typed type definitions using NuGet, or TSD (available via NPM) or just on the GitHub repository.

You can check http://onoffswitch.net/mongoose-with-typescript/ . It also includes a link for a github repository which contains unit tests and schema definition with typescript.

This question was asked in 2013, and since then, things have changed a lot, and none of the given answer mentions how to go about finding declaration files now.

So the answer to the question, where can I find typescript declaration file for mongoose (or for any other library) is to search for such declaration file using TypeSearch

It is a tool developed by the TypeScript team that helps in searching for declaration file hosted on the DefinitelyTyped repository (which has since grown big and now almost impossible to search using the GitHub web interface).

The other thing that has changed since 2013, is that Typings or tsd is no longer the recommended tool for working with declaration files (as mentioned in some of the already given answers). The recommended way is to now use npm. You can read more about this here: The Future Of Declaration Files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM