-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: add code example to process.throwDeprecation property #29495
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2222,11 +2222,28 @@ added: v0.9.12 | |||||
|
||||||
* {boolean} | ||||||
|
||||||
The `process.throwDeprecation` property indicates whether the | ||||||
`--throw-deprecation` flag is set on the current Node.js process. See the | ||||||
The initial value of `process.throwDeprecation` indicates whether the | ||||||
`--throw-deprecation` flag is set on the current Node.js process, | ||||||
`process.throwDeprecation` is mutable, so whether or not deprecation | ||||||
warnings results in an error may be altered at runtime. See the | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
documentation for the [`'warning'` event][process_warning] and the | ||||||
[`emitWarning()` method][process_emit_warning] for more information about this | ||||||
flag's behavior. | ||||||
[`emitWarning()` method][process_emit_warning] for more information. | ||||||
|
||||||
```console | ||||||
$ node --throw-deprecation -p "process.throwDeprecation" | ||||||
true | ||||||
$ node -p "process.throwDeprecation" | ||||||
undefined | ||||||
$ node | ||||||
> process.emitWarning('test', 'DeprecationWarning'); | ||||||
undefined | ||||||
> (node:26598) DeprecationWarning: test | ||||||
> process.throwDeprecation = true; | ||||||
true | ||||||
> process.emitWarning('test', 'DeprecationWarning'); | ||||||
Thrown: | ||||||
{ [DeprecationWarning: test] name: 'DeprecationWarning' } | ||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be worthwhile to include an example that shows process.throwDeprecation = true;
process.emitWarning('test', 'DeprecationWarning');
// will cause an error to be thrown There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally worth it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should docs change? I mean, may say that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be good, I think |
||||||
|
||||||
## process.title | ||||||
<!-- YAML | ||||||
|
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.