With a background in C#, I am familiar with the null-conditional operator which allows you to call a function while avoiding a potential null-reference exception like this:
Func<int> someFunc = null;
int? someInteger = someFunc?.Invoke();
// someInteger == null
Considering that Typescript has its own "optional chaining operator" `.?` with similar functionality, I'm curious if there is a way to achieve the same concise code. The closest solution I can think of involves using a conditional expression:
let someFunc: (() => number) | undefined = undefined;
let someNumber = someFunc !== undefined ? someFunc() : undefined;
Maybe there is a way to leverage apply and call in this scenario?