Better typing of toArray export