New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose internal assert
globally.
#5684
Comments
This was referenced Jun 5, 2020
It doesn't, I think you saw the behaviour where all of the built-in modules are automatically exposed as globals in the REPL. |
Grr... you are right... 😢 (╯°□°)╯︵ ┻━┻ |
I'm reluctant to add non-standard globals. |
In light of #6252 (comment) this issue can be closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While it isn't a browser standard, Node.js includes an
assert()
globally. We heavily useassert()
in the internal code, but at runtime there is noassert()
available.Exposing it as
Deno.assert()
would be problematic in TypeScript because of microsoft/TypeScript#37818 as it would require a type annotation all the time if you tried to destructure it and it looks like it is unlikely to ever be addressed in TypeScript because of design limitations.We have
assert()
instd/testing/asserts.ts
but including a testing module just to be able to do anassert()
seems very heavy weight as it includes two other dependencies as well:So while it isn't ideal to have something in the global namespace that isn't in browsers, it is a minor variation that makes it significantly easier to write better code, especially since
assert()
also provides type narrowing in TypeScript now.The text was updated successfully, but these errors were encountered: