microsoft / microsoft/TypeScript

Allow a module to implement an interface

Open
#420 66 comments 115 reactions 0 assignees View on GitHub
Help Wanted Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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

Example:

``` typescript
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);
```

Contributor guide

Open the contributing guide

Research direction

The issue names no source file, test, or compiler entry point. Start by locating handling for module declarations and interface compatibility, then add coverage for `module Menu implements Showable` and confirm the existing `addShowable(Menu)` example type-checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.