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. iOS - Responder Chain

     在iOS中,当发生事件响应时,必须知道由谁来响应事件.这就是由响应者链来对事件进行响应,所有事件响应的类都是UIResponder的子类,响应者链是一个由不同对象组成的层次结构,其中的每个对象将依次 ...

  2. 【UVA 11354】 Bond (最小瓶颈生成树、树上倍增)

    [题意] n个点m条边的图 q次询问 找到一条从s到t的一条边 使所有边的最大危险系数最小 InputThere will be at most 5 cases in the input file.T ...

  3. 【POJ1743】 Musical Theme (二分+后缀数组)

    Musical Theme Description A musical melody is represented as a sequence of N (1<=N<=20000)note ...

  4. VS2010 C# 调用Web Service .

    转自:http://blog.csdn.net/fenglailea/article/details/7262566 打开VS2010,打开"文件-新建-网站",选择"A ...

  5. Android Training精要(五)讀取Bitmap對象實際的尺寸和類型

    讀取Bitmap對象實際的尺寸和類型 BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecode ...

  6. 集合ArrayList习题练一练——分数

    namespace 集合习题练一练{    class Program    {        static void Main(string[] args)        {            ...

  7. 微软Sharepoint的一些缺点

    转:http://bbs.tianya.cn/post-144-566491-1.shtml 微软Sharepoint的一些缺点(一) 微软Sharepoint的一些缺点 关于SharePoint,它 ...

  8. 获得WCF Client端的本地端口 z

    当WCF调用远程服务时,显示该调用的网速或流量.其中比较关键的一步就是需要获得WCF  Client端的本地端口,原来以为是个简单的事情,结果查了1个多小时谷歌,硬是没找到好的法子,只有自己动手了. ...

  9. Java正则表达式应用总结

    http://lavasoft.blog.51cto.com/ http://lavasoft.blog.51cto.com/62575/179324      Java正则表达式应用总结   一.概 ...

  10. dos攻击与防御

    SYN Flood攻击 标准的TCP三次握手过程如下: 客户端发送一个包含SYN标志的TCP报文,SYN即同步(Synchronize),同步报文会指明客户端使用的端口以及TCP连接的初始序号:  服 ...