Microsoft/TypeScript

Allow a module to implement an interface

Open

#420 创建于 2014年8月10日

在 GitHub 查看
 (66 评论) (115 反应) (0 负责人)TypeScript (48,455 star) (6,726 fork)batch import
Help WantedSuggestion

描述

It would be useful when a module can implement an interface using the implements keyword. Syntax: module MyModule implements MyInterface { ... }.

Example:

interface Showable {
    show(): void;
}
function addShowable(showable: Showable) {

}

// This works:
module Login {
    export function show() {
        document.getElementById('login').style.display = 'block';
    }
}
addShowable(Login);

// This doesn't work (yet?)
module Menu implements Showable {
    export function show() {
        document.getElementById('menu').style.display = 'block';
    }
}
addShowable(Menu);

贡献者指南

Allow a module to implement an interface · Microsoft/TypeScript#420 | Good First Issue