如何在基于Angular2 angular-cli的项目中包含绝对类型的文件 [英] How to include definitely typed files in an Angular2 angular-cli based project

查看:64
本文介绍了如何在基于Angular2 angular-cli的项目中包含绝对类型的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种情况下的最佳做法是什么?

What is the best practice for this scenario:

我已经使用angular-cli(即使用ng new)创建了Angular2项目

I have created an Angular2 project using angular-cli (i.e. using ng new)

我想包括来自绝对键入的TypeScript类型

例如,我应该使用类型来安装类型吗?如何确定ng build中包含的类型?

For example, should I use typings to install the types? How do I make sure the types are included in the ng build?

如果您的回答是我应该以某种方式破解webpack设置,请说明我该怎么做,因为我只有angular-cli.json文件

If you answer is that I should hack the webpack settings somehow, please include how I would do that, since I only have the angular-cli.json file

推荐答案

Angular-cli使用Typescript 2.0,您只需要在npm上搜索类型,比如说要使用jquery类型,只需安装它们即可:

Angular-cli uses typescript 2.0, you just need to search for the typings on npm, say you want jquery types, just install them:

npm install --save @types/jquery

就是这样.更多信息此处

这篇关于如何在基于Angular2 angular-cli的项目中包含绝对类型的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆