-
Notifications
You must be signed in to change notification settings - Fork 30k
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
doc: argument types for assert methods #11548
Conversation
doc/api/assert.md
Outdated
@@ -41,6 +43,9 @@ changes: | |||
pr-url: https://github.com/nodejs/node/pull/5910 | |||
description: Handle non-`Uint8Array` typed arrays correctly. | |||
--> | |||
* `actual` {Object|Primitive} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already usage of {any}
which seems to fit this situation better. Ditto below.
doc/api/assert.md
Outdated
@@ -143,6 +151,9 @@ changes: | |||
pr-url: https://github.com/nodejs/node/pull/3276 | |||
description: The `error` parameter can now be an arrow function. | |||
--> | |||
* `block` {Function} | |||
* `error` {Error|RegExp|Function} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation doesn't mention how anything other than a RegExp
or a Function
(either a constructor or a validation function) would work. I.e., I don't think it can be an Error
object, only an Error
constructor. Ditto for .throws()
.
doc/api/assert.md
Outdated
@@ -9,6 +9,8 @@ test invariants. | |||
<!-- YAML | |||
added: v0.5.9 | |||
--> | |||
* `value` {Boolean|Number} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, technically any value (not just booleans and numbers) would work. I'd be fine with either any
or Boolean
. since the concepts of truthy-ness and falsy-ness are defined by Boolean(val)
.
doc/api/assert.md
Outdated
@@ -243,6 +263,7 @@ assert.fail(1, 2, 'whoops', '>'); | |||
<!-- YAML | |||
added: v0.1.97 | |||
--> | |||
* `value` {Number|String|Error} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any type would work with this function. The examples below are just that -- examples.
73fbc20
to
9b5d9e8
Compare
Thanks for the review - changes made. |
doc/api/assert.md
Outdated
* `actual` {any} | ||
* `expected` {any} | ||
* `message` {String} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can you please remove these spurious/extra new lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
9b5d9e8
to
7c9b677
Compare
doc/api/assert.md
Outdated
@@ -379,6 +410,8 @@ If the values are strictly equal, an `AssertionError` is thrown with a | |||
<!-- YAML | |||
added: v0.1.21 | |||
--> | |||
* `value` {Boolean} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is actually any
given the description below...
doc/api/assert.md
Outdated
@@ -9,6 +9,8 @@ test invariants. | |||
<!-- YAML | |||
added: v0.5.9 | |||
--> | |||
* `value` {Boolean} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be any
, like assert.ok
7c9b677
to
1550375
Compare
1550375
to
d1b6dd3
Compare
Landed in 76e3e49 |
Refs: nodejs#9399 PR-URL: nodejs#11548 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Checklist
Affected core subsystem(s)
documentation
Description of changes
Added argument data types to the docs for the
assert
module.Issue