typings的理解


简介
一些js库扩展了JavaScript的特性和语法,但是TypeScript编译器并不识别,
通过typings.json配置可以辅助IDE,给出有智能的提示信息,以及重构的依据。
因此需要在typings.json文件中配置TypeScript类型定义文件(文件名后缀为.d.ts)

自己的理解
typings就方便TypeScript识别、编译、智能提示TypeScript无法识别的JS库的特性和语法

命令集


#全局安装typings
npm install typings --global

#搜索
typings search module

#查找
typings search --name module
#安装(默认使用npm)
typings install module --save

#使用数据源为dt安装
typings install dt~module --global --save

#其他数据源安装
typings install env~module --global --save
typings install npm~module --save

#可以直接用github,后面为github的项目路径https://github.com/DefinitelyTyped/DefinitelyTyped #后面为提交的版本号,可以不写
typings install github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#38fb591c6eba840e0b53d1110302b8e4fb04652c --global --save

#显示所有引用
cat typings/index.d.ts



数据源
npm - dependencies from NPM
github - dependencies directly from GitHub (E.g. Duo, JSPM)
bower - dependencies from Bower
common - "standard" libraries without a known "source"
shared - shared library functionality
lib - shared environment functionality (mirror of shared) (--global)
env - environments (E.g. atom, electron) (--global)
global - global (window.<var>) libraries (--global)
dt - typings from DefinitelyTyped (usually --global)

转载于:https://www.cnblogs.com/liuyt/p/5688137.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值