toArray is deprecated: Use static library function instead

Hi teams,
I just upgraded to dfx 12.1 and I am now getting a bunch of Buffer-realted deprecation warning (eg. toArray()).
I used to manipulate data with Array, but then .append() got deprecated, with suggestion to use Buffer instead.
So then I was still using stable Arrays for storing while manipulating data with Buffer.
Now conversion back to Array won’t be possible in the future (Buffer.toArray being deprecarted).

Can anyone assist me in understanding what the patterns I should follow here :slight_smile: ?
What data type should I use for small lists of entries very frequently queried that are somewhat frequently updated?


This is telling you to use:


Instead of


It seems like the Buffer module has had significant updates. motoko-base/ at master · dfinity/motoko-base · GitHub

Oh boy, that was so simple… thanks amigo!

1 Like

I think my mistake comes from the fact that the VS code extension for motoko does not seem to be up to date with latest motoko versions


Amazing :heart:
Thank you :slight_smile:

1 Like

@rvanasa do you think we could add a motoko:version config to the vscode extension, or infer it from project config files?

As a quick update here, this is fixed in the past several versions of the VS Code extension.

@kpeacock Yep—we could use dfx.json to infer the compiler version.

1 Like