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的更多相关文章

  1. tensorboard No graph definition files were found No scalar data was found 解决方法

    logdir后面的路径不要加引号!!!! tensorboard --logdir='D:\WorkSpace\eclipse\tf_tr\train\my_graph\' 删除引号,改为: tens ...

  2. [TypeScript] Using Typings and Loading From node_modules

    Using TypeScript when installing packages from npm often requires you to install related definition ...

  3. [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 ...

  4. [TypeScript] Understanding Generics with RxJS

    Libraries such as RxJS use generics heavily in their definition files to describe how types flow thr ...

  5. 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 ...

  6. 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 ...

  7. 基于Typescript和Jest刷题环境搭建与使用

    写在前面 前几个月在公司用vue3和ts写项目,想巩固一下基础,于是我想起了去年基于JavaScript和Jest搭建的刷题环境,不如,给它搞个加强版,结合Typescript和Jest 搞一个刷题环 ...

  8. 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 ...

  9. 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  ...

随机推荐

  1. 保存项目文件“XXX.csprj”时出错。类没有注册。

    [出错提示]保存项目文件“XXX”时出错.类没有注册.正在查找具有CLSID的对象:{D9B3211D-E57F-4426-AAEF-30A806ADD397}. [解决办法] 需要安装:MSXML_ ...

  2. 欧几里得旅行商问题 java与c++实现

    双调欧几里得旅行商问题是一个经典动态规划问题.<算法导论(第二版)>思考题15-1 旅行商问题描述:平面上n个点,确定一条连接各点的最短闭合旅程.这个解的一般形式为NP的(在多项式时间内可 ...

  3. Steam游戏黑屏与游戏直接安装方法

    黑屏原因主要是360禁止了反作弊进程,解决方法: Steam游戏目录: Steam\steamapps\common\*** 例如黎明杀机,备份时候可直接备份该目录下 Dead by Daylight ...

  4. settimeout vs setinternal

    http://blog.sina.com.cn/s/blog_6b1ab3be0100pzmo.html http://www.360doc.com/content/11/0412/17/100779 ...

  5. Cloud Insight!StatsD 系监控产品新宠!

    年关将至,Cloud Insight 正式版悄然上线了.没有大张旗鼓的宣传,也没有热热闹闹的庆祝,只是一群人在上线前踏踏实实的优化了两周,然后发版,就是这样一件简单的事. 然而就是这样一个低调的产品, ...

  6. WEB SSH之Shellinabox

    用起来方便的,参考URL: http://lzw.me/a/shellinabox.html 生成 pem 证书,可以 https 方式启动.pem 证书的格式为公钥加私钥,并以 x509 的格式进行 ...

  7. 【NOIP2015 DAY1 T3 】斗地主(landlords)

    题目描述 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来进行的扑克牌游戏.在斗地主中,牌的大小关系根据牌的数码表示如下:3<4< ...

  8. MVVM_Android-CleanArchitecture

    前言 "Architecture is About Intent, not Frameworks" - Robert C. Martin (Uncle Bob) Uncle Bob ...

  9. 17.1.1.2 Setting the Replication Slave Configuration

    17.1.1.2 Setting the Replication Slave Configuration 在一个复制slave, 你必须创建一个唯一的server ID,如果这个没有做,slave设置 ...

  10. RelativeLayout常用属性介绍

    RelativeLayout常用属性介绍 转自: http://www.douban.com/note/97496783/ 下面介绍一下RelativeLayout用到的一些重要的属性: 第一类:属性 ...