This lesson covers using your first TypeScript Interface and what happens to the Interface when it is compiled down to JavaScript.

Define the interfaces:

// interfaces.ts

export interface Person {
name: String
} export interface SocialNetwork{
title: String;
getPeople(): Person[];
}

Use interface:

import {SocialNetwork} from './interfaces';

class SocialNetworks implements SocialNetwork{
title = "Facebook"; getPeople(){
return [{name: 'John'}]
}
} new SocialNetworks();

To notice that, interfaces won't output to the js file, it is just used when compile time.

[TypeScript ] What Happens to Compiled Interfaces的更多相关文章

  1. TypeScript: type alias 与 interface

    官方文档中有关于两者对比的信息,隐藏在 TypeScript Handbook 中,见 Interfaces vs. Type Aliases 部分. 但因为这一部分很久没更新了,所以其中描述的内容不 ...

  2. typescript handbook 学习笔记3

    概述 这是我学习typescript的笔记.写这个笔记的原因主要有2个,一个是熟悉相关的写法:另一个是理清其中一些晦涩的东西.供以后开发时参考,相信对其他人也有用. 学习typescript建议直接看 ...

  3. TypeScript - Interfaces

    简介 关注于数据值的 ‘shape’的类型检查是TypeScript核心设计原则.这种模式有时被称为‘鸭子类型’或者‘结构子类型化’. . 在TypeScript中接口interfaces的责任就是命 ...

  4. Why does Typescript use the keyword “export” to make classes and interfaces public?

    原文: https://stackoverflow.com/questions/15760462/why-does-typescript-use-the-keyword-export-to-make- ...

  5. [TypeScript] Using Interfaces to Describe Types in TypeScript

    It’s easy to pass the wrong value to a function. Typescript interfaces are great because they catch ...

  6. [TypeScript] Typescript Interfaces vs Aliases Union & Intersection Types

    TypeScript has 'interface' and 'type', so when to use which? interface hasName { firstName: string; ...

  7. [TypeScript] Loading Compiled TypeScript Files in Browser with SystemJS

    TypeScript outputs JavaScript, but what are you supposed to do with it? This lesson shows how to tak ...

  8. VSCode typescript ctrl+shift+b can't be compiled error:TS5007

    环境: vscode:1.12.2 node 7.4.0 TypeScript:2.3.2 从svn 更新下来,别的电脑环境编译是没问题的,在我的电脑上编译失败并出现以下错误 error TS5007 ...

  9. [Typescript] What is a Function Type ? Function Types and Interfaces - Are They Related ?

    Function Type: type messageFn = (name: string) => string; function sayHello(name: string): string ...

随机推荐

  1. 让IIS识别PUT和DELETE请求

    转眼间年底了,突然的我就挪了窝.新的公司,新的电脑,新的服务器....面对新环境,手有些痒,于是试着编写自己的简易版restful API. restful的话,对资源的相应操作应该被体现成http动 ...

  2. 第 12 章 命令模式【Command Pattern】

    以下内容出自:<<24种设计模式介绍与6大设计原则>> 今天讲命令模式,这个模式从名字上看就很简单,命令嘛,老大发命令,小兵执行就是了,确实是这个意思,但是更深化了,用模式来描 ...

  3. Eclipse里初次使用Maven注意问题

    在Eclipse里初次使用Maven,右键project->add dependency, 发现search不管用,这时候需要按照以下步骤操作: Goto "Preferences - ...

  4. AD10 gerber生成,及导入cam350 多图详细步骤

    Protel99转Gerber文件导入到CAM350中看为什么钻孔层偏位 这是因为你导入CAM350 时的格式没有设置正确.你用PROTEL 导出钻孔 TXT 时记住是什么格式,例如: 2:3,2:4 ...

  5. bzoj3238

    都LCP了很显然是要用到后缀数组的 显然前面的那个东西是可以直接算出来的 关键在于LCP的和怎么快速的计算 不难想到穷举height[i],然后判断这个height[i]可能成为多少对后缀的LCP 考 ...

  6. poj2154

    利用bzoj2705的结论我们很容易优化这道等价类计数的问题 sum(n^gcd(i,n))/n mod p (1<=i<=n) =sum(phi(n/L)*n^L)/n mod p (n ...

  7. C#的装箱和拆箱

    1:装箱 其实就是将一个值类型的转换成一个引用类型,或者把值类型转换成一个被该值类型那个应用的接口类型,这个过程会使用堆栈.被装箱的值是作为一个复制赋给对象的. int  intValue = 100 ...

  8. 【转】iOS Provisioning Profile(Certificate)与Code Signing详解 -- 待看

    原文网址:http://blog.sina.com.cn/s/blog_82c8198f0102vy4j.html 引言 关于开发证书配置(Certificates & Identifiers ...

  9. Uninstall Tool 3.3.2.5315 简体中文注册版(彻底卸载软件)

    Uninstall Tool Uninstall Tool是CrystalIdea Software出品的一款强大而灵活的Windows标准“添加/删除程序”工具的替代软件.它能快速,安全而方便的删除 ...

  10. 遍历form表单

    //表单 var form = new Ext.form.FormPanel({ //创建表单面板 labelAlign: 'center', //水平对齐方式 layout: 'form', //布 ...