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. chmod 命令 set uid ,set gid,sticky bit 说明

    permission的符号模式表: 模式 名字 说明 r 读 设置为可读权限 w 写 设置为可写权限 x 执行权限 设置为可执行权限 X 特殊执行权限 只有当文件为目录文件,或者其他类型的用户有可执行 ...

  2. Xcode7.01相对于底版本的变动小结

    1.在Xcode7中系统不再自动支持http请求,需要配置plist才能使用http: 2.appdelegate中的self.window不再支持直接往window上加view,必须先给window ...

  3. Java多线程初学者指南(10):使用Synchronized关键字同步类方法

    要想解决“脏数据”的问题,最简单的方法就是使用synchronized关键字来使run方法同步,代码如下: public synchronized void run() { ... } 从上面的代码可 ...

  4. VisualSvn Server安装和使用

    原文地址:http://www.cnblogs.com/jiahuafu/archive/2012/12/22/2828955.html VisualSvn Server介绍 1 .VisualSvn ...

  5. OA学习笔记-002-Sruts2.1配置

    一.jar commons-fileupload-1.2.1.jarcommons-io-1.3.2.jarfreemarker-2.3.15.jarognl-2.7.3.jarstruts2-cor ...

  6. 【Xamarin挖墙脚系列:最重要的布局ListView】

    原文:[Xamarin挖墙脚系列:最重要的布局ListView] 安卓的几个重要的布局 线性布局 相对布局  Table布局 Tab布局  表格Grid布局 列表布局. 这几种基本的布局的方式,最重要 ...

  7. JAVA 内存泄漏与内存溢出

    一.Java内存回收机制 不论哪种语言的内存分配方式,都需要返回所分配内存的真实地址,也就是返回一个指针到内存块的首地址.Java中对象是采用new或者反射或者clone或者反序列化的方法创建的, 这 ...

  8. Linux修改文件时候出现崩溃,产生了一个.swap交换文件,如何修复?

    有时候在用vim打开文件时提示类似以下的信息: E325: 注意 发现交换文件 ".exportcert.cpp.swp" 所有者: liuchuanliang    日期: Th ...

  9. (转载)Javascript操作表单之间的数据传递

    (转载)http://www.aspxhome.com/javascript/skills/200710/214825.htm 今天有朋友问我关于用JAVASCRIPT来进行页面各表单之间的数据传递的 ...

  10. Leveraging the Power of Asynchrony in ASP.NET [转]

    Asynchronous programming has had a lot of attention in the last couple of years and there are two ke ...