首页 > 移动平台 > 详细

[TypeScript ] What Happens to Compiled Interfaces

时间:2016-06-10 06:04:41      阅读:240      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/5573063.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!