This repository was archived by the owner on Nov 18, 2025. It is now read-only.
feat: add type parameter to warn function#1009
Merged
alicejli merged 8 commits intogoogleapis:masterfrom May 24, 2021
Merged
Conversation
Contributor
summer-ji-eng
left a comment
There was a problem hiding this comment.
For lint issue, you could run npm run fix and npm run lint
src/warnings.ts
Outdated
| const emittedWarnings = new Set<string>(); | ||
|
|
||
| export function warn(code: string, message: string) { | ||
| // Type is the type of warning (e.g. 'DeprecationgWarning', 'ExperimentalWarning', etc.) |
Contributor
There was a problem hiding this comment.
Nice. Thanks for adding the comments.
src/warnings.ts
Outdated
Comment on lines
+32
to
+36
| if (type !== 'undefined') { | ||
| process.emitWarning(message, type); | ||
| } else { | ||
| process.emitWarning(message); | ||
| } |
Contributor
There was a problem hiding this comment.
Could you add a unit test here?
https://github.com/googleapis/gax-nodejs/blob/master/test/unit/warning.ts
Contributor
summer-ji-eng
left a comment
There was a problem hiding this comment.
Leave one comment, other than that, LGTM
Thanks for your work.
summer-ji-eng
approved these changes
May 24, 2021
src/warnings.ts
Outdated
| console.warn(message); | ||
| } else { | ||
| process.emitWarning(message); | ||
| if (typeof warnType !== 'undefined') { |
Contributor
There was a problem hiding this comment.
nit(style): please merge this into one if-else if-else chain to reduce nesting :)
alexander-fenster
approved these changes
May 24, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding a type parameter to the warn function in preparation for emitting a DeprecationWarning for deprecated methods/services.(https://github.com/googleapis/gapic-generator-typescript/issues/853)
Fixes googleapis/google-cloud-node-core#371 🦕