Currently when you use BigInt literals, runkit will give you an syntax error: Identifier directly after number (1:1)
It is possible to workaround this issue with eval
or by using the BigInt constructor but it would be nice to have this feature built into runkit.
BigInts are available in Node 10.4 and higher.
And the result field only shows BigInt {}
instead of the value.
Can you give us a screenshot, code or a way to reproduce this error?
You can reproduce the bug like this:
// This works:
const myBinInt = BigInt(5);
// This causes a syntax error in the editor: (Identifier directly after number)
const otherBigInt = 5n;
// The version of node RunKit uses supports it, as evidenced by this eval statement:
const anotherBigInt = eval('5n');
So this error is likely from the checks being done on the code before it is even sent to the server.
If you’re using Babel to parse the code, this plugin can be used to add support for BigInt literals:
1 Like
Umm, now it is 2023 and BigInt literals are still not supported!?
Tell me it’s a joke! Or I’ve just missed something?
As a workaround, you can currently access BigInts by doing eval(“10n”) for example. Also, any library that uses BigInt literals should work as well. Basically, it is just the editor itself that doesn’t allow it, not the underlying engine. Yes, we know you shouldn’t have to do that. But it gets you the feature right now if you want to use it. We are working on making it directly accessible.