Fix type error when length applies to array not object.