Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict interface implementation #20537

Closed
Alacrit opened this issue Dec 7, 2017 · 1 comment
Closed

Strict interface implementation #20537

Alacrit opened this issue Dec 7, 2017 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@Alacrit
Copy link

Alacrit commented Dec 7, 2017

TypeScript Version: 2.6.1

Code

interface IEmpty {
}

interface IParam {
    param: number;
}

interface IFn<T> {
    fn(param: T): void;
}

class MyClass implements IFn<IParam> {
    // Wrong param interface implementation (only if empty)
    // Wrong return type implementation
    // But no compiler errors - WHY? How to avoid this?
    fn(param: IEmpty): string {
        return 'fnResult';
    }
}

Expected behavior:
Compiler error. Or any way to force compiler to do EmptyParamTypeCheck and VoidReturnTypeCheck.

Actual behavior:
No errors.

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Dec 7, 2017
@RyanCavanaugh
Copy link
Member

Both your questions are answered in the FAQ https://github.com/Microsoft/TypeScript/wiki/FAQ

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants