The main issue here is your question itself. When you say that A extends B ? true : false
, it will be true
if and only if A
is assignable to B
and false
otherwise. Now, let's now look at your question again:
Why does this unknown definitely not extend any[]?
unknown
is a type that is explicitly named for forcing you as a developer to not take any guarantees on the shape of the data. Therefore, you cannot assign unknown
to anything except any
and unknown
. You are instead supposed to get the shape of the data by inferring it via checks (if statements like typeof foo === "string"
) or direct casts (foo as boolean
).
Therefore, when you ask why does unknown
not extend any[]
you are asking why is unknown
not assignable to any[]
. The reason for this is because when you say that unknown
is assignable to any[]
then you are making an unsafe guarantee that the data is in fact an array. The fact that the item within the array is any
does not matter because you are still saying that the data should have all of the methods and index signatures of the array type. I hope this helps clear things up for you/