1

An interface declares a function that accepts a function as a parameter. Why the compiler does not throw an error if an implementation doesn't have such parameter? Is there a possibility to force this behaviour?

interface Iterable2<T> {
    iterate(callback: (element: T) => void): void;
}

class NumberIterable2 implements Iterable2<number> {
    iterate(): void {
        // no error?
    }
}

Tested with:

deno 1.19.0 (release, x86_64-pc-windows-msvc)
v8 9.9.115.7
typescript 4.5.2
1

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.