[TypeScript ] What Happens to Compiled Interfaces

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TypeScript ] What Happens to Compiled Interfaces相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

happen-before原则

happen-before 原则理解

happen-before原则的理解

java并发编程(十六)happen-before规则

happen-before 规则

Java -- 每日一问:Java内存模型中的happen-before是什么?