Recently, I encountered a situation where typescript seems to be incorrectly narrowing the given type.
(value: number[] | null) => {
if ((value?.length ?? 0) > 0) value[0];
};
Even though the condition will not be true if the value is null, in the if branch it still shows me an 'Object is possibly 'null'' error message.
Should this type be narrowed and why or why not?
If this behavior is expected, are there any convenient workarounds available?