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. Forget asp.net membership,ASP.NET Identity Overview

    http://www.asp.net/identity http://www.asp.net/identity/overview/getting-started/introduction-to-asp ...

  2. iOS --- 取整数

    Objective-C拓展了C,自然很多用法是和C一致的.比如浮点数转化成整数,就有以下四种情况. 1.简单粗暴,直接转化 float f = 1.5; int a; a = (int)f; NSLo ...

  3. 定位- CLGeoencoder - 反编码

    #import "ViewController.h" #import "MBProgressHUD+MJ.h" #import <CoreLocation ...

  4. 移动web HTML5使用photoswipe模仿微信朋友圈图片放大浏览

    先来几张效果图: 点击其中一张照片可放大,可支持图片文字描述: 同时支持分享功能: 支持手势放大缩小 使用js框架是PhotoSwipe. PhotoSwipe是一个图片放大插件,兼容pc和移动端,经 ...

  5. 第十二周项目一 教师兼干部类】 共建虚基类person

    项目1 - 教师兼干部类]分别定义Teacher(教师)类和Cadre(干部)类,采用多重继承方式由这两个类派生出新类Teacher_Cadre(教师兼干部).要求: (1)在两个基类中都包含姓名.年 ...

  6. 成都OpenPart——DevOps专场活动参与感

    今天下午去参加了成都OpenPart——DevOps专场,感觉很好. 题外话: 回想一下,工作将近四年了,这是第一次参加类似的活动.自从结婚带了小孩以后,就基本上每个周末奔波工作和家里两个城市之间,这 ...

  7. 第 2 章 代理模式【Proxy Pattern】

    第 2 章 代理模式[Proxy Pattern] 以下内容出自:24种设计模式介绍与6大设计原则.pdf 什么是代理模式呢?我很忙,忙的没空理你,那你要找我呢就先找我的代理人吧,那代理人总要知道被代 ...

  8. CISCO的HTTP/HTTPS/SSH配置测试完成

    按实验一步一步,倒是很容易的,也理解罗~~ START-CONFIG粗配置文件如下: r1#show run Building configuration... Current configurati ...

  9. 【HDU 5456】 Matches Puzzle Game (数位DP)

    Matches Puzzle Game Problem Description As an exciting puzzle game for kids and girlfriends, the Mat ...

  10. C++ STL 算法精选之查找篇

    1.查找类算法 adjacent_find(first,last); 查找区间[first,last)内第一次出现连续的两个相等的元素,并返回指向第一个元素的迭代器,连续元素之间的比较,默认是== a ...