2

I am implementing a function that returns an Awaitable<T>- but for the moment, I just want to return a placeholder value.

How do I accomplish this?

In rust, I'd so something like invoke the unimplemented!() macro - in java/python, I'd return null or raise an exception

nz_21
  • 6,140
  • 7
  • 34
  • 80

1 Answers1

2

Control that always reaches an exception is a bottom type, so you can raise an exception to get any type:

function unimplemented<T>(): T {
  throw new Exception("Unimplemented!");
}

If you want a usable placeholder value at runtime from your function, your only option is indeed null and a bunch of nullable annotations.

concat
  • 3,107
  • 16
  • 30