Skip to content

Erroneously implementing Interface doesn't throw an error #146

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

Closed
Tarnadas opened this issue Jun 21, 2018 · 3 comments
Closed

Erroneously implementing Interface doesn't throw an error #146

Tarnadas opened this issue Jun 21, 2018 · 3 comments

Comments

@Tarnadas
Copy link

interface SomeInterface {
  someMethodWhichShouldBeImplemented: () => void;
}

class SomeClass implements SomeInterface {
  // no implementation of 'someMethodWhichShouldBeImplemented' here
}

This code would still compile instead of throwing an error.

@dcodeIO
Copy link
Member

dcodeIO commented Jun 21, 2018

Note that interfaces aren't implemented yet. In order to be able to annotate them already (i.e. when sharing code with TS) the compiler simply doesn't emit errors.

@andy-hanson
Copy link
Contributor

This is also a problem with extends in templates:

interface HasX { x: i32 }
function f<T extends HasX>(x: T): i32 {
	return x.x;
}

class C { x: i32; }
class D { D: boolean; }

export function test(c: C, d: D): i32 {
	return f(c) + f(d);
}

There is a compile error, but it happens inside the body of the function rather than at the call site f(d) which could be confusing if you don't know which caller is the problem.

@dcodeIO
Copy link
Member

dcodeIO commented May 27, 2020

Closing this issue as part of 2020 vacuum because seems to be outdated. Consider opening a new issue if necessary!

@dcodeIO dcodeIO closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants