I am trying to create a type that map a tuple like this:
[number, string | undefined, number | undefined, string | null]
to
[number, string , number, string]
But I am not able to do it.
I tried something like this but obviously does not work
type FilterUndefined<T extends readonly unknown[]> = T extends readonly [infer H, ...infer R] ?
H extends undefined ? null : [H, ...FilterUndefined<R>] : T
This question sounds similar, but it extracts from an object.
Any help is appreciated.