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)
posted @ 2016-07-20 14:03  Liuyt  阅读(9797)  评论(0编辑  收藏  举报