An error occurs when trying to compile the following code: "a function whose declared type is neither void nor any must return a value or consist of a single throw statement."
Is there a way to indicate to the compiler that _notImplemented throws an exception?
function _notImplemented() {
throw new Error('not implemented');
}
class Foo {
bar() : boolean { _notImplemented(); }
The only workaround I can think of is to use generics, but it feels like a hack. Is there a more elegant solution?
function _notImplemented<T>() : T {
throw new Error('not implemented');
}
class Foo {
bar() : boolean { return _notImplemented(); }