[TypeScript] Generating Definition Files
TypeScript allows you to generate definition files for your own libraries. This lesson shows you how to organize your project and generate the definition files so that others projects can use your library with TypeScript.
If you're writing a library and you want to generate your own definition files, just make sure and add declaration to your tsconfig:
{
"compilerOptions": {
"rootDir": "src",
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "./dist",
"noEmitOnError": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
An error that will show up sometimes, it'll say you'll have a duplicate definition of app, so you want to make sure in your tsconfig you've excluded dist, so that you avoid having these duplicate definitions.
{
"compilerOptions": {
...
},
"exclude": [
"node_modules",
"dist",
"typings/main",
"typings/main.d.ts"
]
}
To let other people easily import your stuff, you can create a index.tx is dist:
// index.ts export * from './main';
export * from './interfaces';
Export everythinig they need in index.ts file.
So they can do:
import {App, Person, SocialNetwork} from 'Your-Lib'
For typings, in package.json:
"typings": "./dist/index.d.ts"
that way, when that package gets added to typing and someone loads it up, they'll get this index file, and then they'll have access to everything off of how we structured our library.
[TypeScript] Generating Definition Files的更多相关文章
- tensorboard No graph definition files were found No scalar data was found 解决方法
logdir后面的路径不要加引号!!!! tensorboard --logdir='D:\WorkSpace\eclipse\tf_tr\train\my_graph\' 删除引号,改为: tens ...
- [TypeScript] Using Typings and Loading From node_modules
Using TypeScript when installing packages from npm often requires you to install related definition ...
- [TypeScript] Using Lodash in TypeScript with Typings and SystemJS
One of the most confusing parts of getting started with TypeScript is figuring out how to use all th ...
- [TypeScript] Understanding Generics with RxJS
Libraries such as RxJS use generics heavily in their definition files to describe how types flow thr ...
- What you should know about .so files
In its early days, the Android OS was pretty much supporting only one CPU architecture: ARMv5.Do you ...
- JavaScript Libraries In A TypeScript Application, Revisited
If you haven’t already gotten involved with it, you’ll probably know that TypeScript is becoming inc ...
- 基于Typescript和Jest刷题环境搭建与使用
写在前面 前几个月在公司用vue3和ts写项目,想巩固一下基础,于是我想起了去年基于JavaScript和Jest搭建的刷题环境,不如,给它搞个加强版,结合Typescript和Jest 搞一个刷题环 ...
- Embed dll Files Within an exe (C# WinForms)—Winform 集成零散dll进exe的方法
A while back I was working on a small C# WinForms application in Visual Studio 2008. For the sake of ...
- How To Use XDOLoader to Manage, Download and Upload Files? (文档 ID 469585.1)
Applies to: BI Publisher (formerly XML Publisher) - Version 5.6.3 to 5.6.3 [Release 5] Information ...
随机推荐
- iOS开发之国际化
iOS 国际化.根据系统不同的语言自动切换. 首先.选择项目 Add new file -->iOS -->Resource -->Strings File . 命名为Locali ...
- String的一些细节
String 常量池问题 (1) 字符串常量的"+"号连接,在编译期字符串常量的值就确定下来, 拿"a" + 1来说,编译器优化后在class中就已经是a1. ...
- Ubuntu 14.04安装Chromium浏览器并添加Flash插件Pepper Flas
转自Ubuntu 14.04安装Chromium浏览器并添加Flash插件Pepper Flash Player Chromium谷歌的开源浏览器将不再支持Netscape浏览器插件API,Adobe ...
- 李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档
李洪强iOS开发之-环信02.1_环信 SDK 2.x到3.0升级文档 SDK 2.x 至 3.0 升级指南 环信 SDK 3.0 升级文档 3.0 中的核心类为 EMClient 类,通过 EMCl ...
- Qt无边框MainWindow如何拖动四周改变大小
原来还有winEvent(), x11Event() and macEvent() 这些东西...不过貌似还需要找更好的办法,否则就无法跨平台了. 你需要重新处理部分窗体事件,以下代码适用于Windo ...
- OSS研究
在以前没有毕业之前,做过了一个了播放器,其实就是mplayer的二次开发. 如果在这个播放器之上,加个oss作声音输入,那不就可以做个卡拉OK啦? 1.OSS的定义 OSS(Open Sound Sy ...
- 队列的实现(JAVA)
定义 队列(queue)是一种特殊的线性表,它只允许在表的前端进行删除,在表的后端进行插入. 进行插入端的称为队尾,进行删除端的称为队头.队列是先进先出原则的.队列的实现同样可以 使用两种方式来 ...
- git推送本地分支到远端 以及删除远端分支的 命令
git推送本地分支到远端 当前处于master分支,尝试用了git push origin warning: push.default is unset; its implicit value is ...
- ☀【CSS3】背景图片
CSS3全新的背景图片方案http://www.cnblogs.com/rubylouvre/p/3401125.html
- Windows Server基础架构云参考架构:硬件之上的设计
作者 王枫 发布于2014年1月27日 综述 毫无疑问,移动互联网.社交网络.大数据和云计算已经成为IT发展的四个大的趋势.其中云计算又为前三个提供了一个理想的平台.今天不仅互联网公司,很多传统行业的 ...