typescript 如何从 github:DefinitelyTypes 安装 .d.ts 文件使用类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35210612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:15:20  来源:igfitidea点击:

How to install .d.ts file from github:DefinitelyTypes using typings

typescriptdefinitelytypedtsd

提问by pierrebo

I used tsd which is now deprecated and am trying to use typings. The typings repository is very small, and I can't find any of the d.ts files I need. All the files I need are in GitHub DefinitelyTyped repository, but I can't find a way to install them using typings.

我使用了现在已弃用的 tsd 并且正在尝试使用类型。打字库很小,我找不到任何我需要的 d.ts 文件。我需要的所有文件都在 GitHub absoluteTyped 存储库中,但我找不到使用类型安装它们的方法。

Here is a command I tried:

这是我尝试过的命令:

typings install github:DefinitelyTyped/DefinitelyTyped/angular-formly/angular-formly.d.ts

I receive the error:

我收到错误:

typings ERR! message Attempted to compile "angular-formly" as a dependency, 
but it contains some ambient module declarations
("AngularFormly", "angular-formly").

Any clue?

有什么线索吗?

回答by Amid

To install angular-formly definitions from DefinitelyTyped, use the following command:

要从绝对类型安装角度形式的定义,请使用以下命令:

typings install angular-formly --ambient

It's taken directly from here: Quick Start

直接取自这里:快速入门

EDIT: Because this is the accepted answer and syntax has changed, as of typings 1.0:

编辑:因为这是公认的答案并且语法已更改,从类型 1.0 开始:

typings install dt~angular-formly --global

回答by Ofer Herman

As of version 1.X of typings the syntax has changed and is now:

从类型 1.X 版本开始,语法已更改,现在是:

typings install dt~angular-formly --global

update: As of typescript 2.0 types are installed using npm: npm install @types/angular-formly

更新:从 typescript 2.0 类型开始,使用 npm 安装: npm install @types/angular-formly

回答by Droogans

I use the following:

我使用以下内容:

./node_modules/.bin/typings install whatever --save --global --source dt

Seems to be the way to do it in v1.3.1.

似乎是在 v1.3.1 中做到的方式。