简体   繁体   English

mongoose的打字稿声明文件

[英]Typescript declaration file for mongoose

Is there a typescript declaration file for mongoose? 是否有mongoose的打字稿声明文件? I've looked at Boris Yankov's Definitely Typed repo, but there does not seem to be one. 我看过Boris Yankov的Definitely Typed回购,但似乎没有。 Anyone know where I can get a good d.ts file for the mongoose library? 任何人都知道我可以在哪里获得mongoose库的优秀d.ts文件?

Kind regards as always. 亲切的问候一如既往。

I found a github project here . 我在这里找到了一个github项目。 It has the mongoose typescript definitions in there. 它有mongoose打字稿定义。

Just an update on this. 只是对此的更新。 Now you should use typings to import your types definitions inside your application. 现在,您应该使用typings在应用程序中导入类型定义。

Use npm and install it globally: 使用npm并全局安装:

$sudo npm install -g typings $ sudo npm install -g typings

to install the mongoose package: 安装mongoose包:

$ typings install mongoose $ typings安装mongoose

More info about typings: https://www.npmjs.com/package/typings 有关typings的更多信息: https ://www.npmjs.com/package/typings

Tutorial on how to setup mongoose with typings in typescript project: http://www.vandiest.biz/?p=3931 有关如何在打字稿项目中设置mongoose类型的教程: 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 . 当然,添加它只是时间问题: Mongoose的绝对类型定义

You can get all of the Definitely Typed type definitions using NuGet, or TSD (available via NPM) or just on the GitHub repository. 您可以使用NuGet或TSD(可通过NPM获得)或仅在GitHub存储库中获取所有绝对类型定义。

You can check http://onoffswitch.net/mongoose-with-typescript/ . 你可以查看http://onoffswitch.net/mongoose-with-typescript/ It also includes a link for a github repository which contains unit tests and schema definition with typescript. 它还包含一个github存储库的链接,其中包含单元测试和带有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. 这个问题在2013年被问到,从那时起,情况发生了很大变化,并且没有一个给出的答案提到如何现在寻找声明文件。

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 所以问题的答案,我在哪里可以找到mongoose(或任何其他库)的typescript声明文件是使用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). 它是由TypeScript团队开发的一个工具,它有助于搜索在DefinitelyTyped存储库上托管的声明文件(后来它变得越来越大,现在几乎不可能使用GitHub Web界面进行搜索)。

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). 自2013年以来发生变化的另一件事是, Typingstsd不再是使用声明文件的推荐工具(如已经给出的一些答案中所述)。 The recommended way is to now use npm. 推荐的方法是现在使用npm。 You can read more about this here: The Future Of Declaration Files 你可以在这里阅读更多相关信息: 宣言文件的未来

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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