For JS modules that accept a number argument but which really only wants an integer, for example, a `concurrency` argument, does it make sense to only accept a BigInt when that's available? It's annoying having to write manual integer type-checks every time.
-
-
Why though? It's probably less efficient than Number right now, but it will be optimized in the future, and for almost all of my use-cases, the difference is negligible.
-
Using BigInt would also have the benefit of no implicit coercion, and when using TypeScript, the argument could be validated statically in the editor. I honestly don't see any practical downsides.
- 7 more replies
New conversation -
-
-
Yes, I'd recommend continuing to use Number when the argument will always be within that range. I'm wondering if it'd make sense to use WebIDL for cases like this, if we had a good way to generate a JS wrapper to insert the write casts/checks.
-
Is there a getting started tutorial for WebIDL? E.g. if it were available as an npm
. - 7 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.