Set.prototype.difference() seems to work
Are the new Set operations supported in the Convex JS runtime?
Spefically e.g. Set.protoype.difference()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference
Thanks 🙂
MDN Web Docs
Set.prototype.difference() - JavaScript | MDN
The difference() method of Set instances takes a set and returns a new set containing elements in this set but not in the given set.
4 Replies
It seems like setting
"lib": ["ESNext", "dom"],
in tsconfig.json
allows the new Set methods to work.
I tested it with this simple Convex query which seemed to run fine in the dashboard:
`ts
export const testSet = query({
args: {},
handler: async (ctx, args) => {
const set = new Set(['a', 'b']);
const set2 = new Set(['b', 'c']);
const difference = set.difference(set2);
console.log(difference.size);
},
});
Yep that's right, we're using a pretty recent V8
would be nice to expose exactly how recent in the future, but it's quick to test these for now with a custom query in the dashboard

although we do need to update our TypeScript types there still