how to install typescript definitions from github repo

萝らか妹 提交于 2019-12-02 02:45:22

问题


how do you install the typescript defs for a library like aurelia-validatejs?

Like the I did the npm install aurelia-validatejs --save to add it to the package.json and node_modules folders. Is there a typings command to get the typescript definitions into the typings.json and typings/globals folder? If not how can I do it.

The library src and typescript exports are located at in the aurelia/validatejs github repo

In case its relevant, I am playing in a project based on the aurelia webpack-typescript skeleton and I want to get validatejs and or other plugins working! It would be really cool if there was a blog post showing how to do plug in installs into the webpack-typescript skelton.


回答1:


With a command:

typings install github:aurelia/validatejs/dist/aurelia-validatejs.d.ts#ee3479eb6edacb31e2a1b7fdc8871e615970d293 --save --global

Or you can manually add it to your typings.json file:

{
    "name": "Test",
    "version": false,
    "globalDependencies": {
        "aurelia-validatejs": "github:aurelia/validatejs/dist/aurelia-validatejs.d.ts#ee3479eb6edacb31e2a1b7fdc8871e615970d293"
    }
}

And run typings install after this.

From documentation (see "Valid Locations")

aurelia/validatejs - is org/repo

dist/aurelia-validatejs.d.ts - is the path

ee3479eb6edacb31e2a1b7fdc8871e615970d293 - is a commit




回答2:


Use this command, this will surely helpful

typings install package_name --ambient --save

It will save package_name to typings.json, for further reference.



来源:https://stackoverflow.com/questions/37691996/how-to-install-typescript-definitions-from-github-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!