-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: add type parameter to warn function #1009
Conversation
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.
For lint issue, you could run npm run fix
and npm run lint
src/warnings.ts
Outdated
@@ -18,7 +18,8 @@ import {isBrowser} from './isbrowser'; | |||
|
|||
const emittedWarnings = new Set<string>(); | |||
|
|||
export function warn(code: string, message: string) { | |||
// Type is the type of warning (e.g. 'DeprecationgWarning', 'ExperimentalWarning', etc.) |
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.
Nice. Thanks for adding the comments.
src/warnings.ts
Outdated
if (type !== 'undefined') { | ||
process.emitWarning(message, type); | ||
} else { | ||
process.emitWarning(message); | ||
} |
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.
Could you add a unit test here?
https://github.com/googleapis/gax-nodejs/blob/master/test/unit/warning.ts
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.
Leave one comment, other than that, LGTM
Thanks for your work.
src/warnings.ts
Outdated
@@ -28,6 +29,12 @@ export function warn(code: string, message: string) { | |||
if (isBrowser()) { | |||
console.warn(message); | |||
} else { | |||
process.emitWarning(message); | |||
if (typeof warnType !== 'undefined') { |
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(style): please merge this into one if-else if-else chain to reduce nesting :)
Adding a type parameter to the warn function in preparation for emitting a DeprecationWarning for deprecated methods/services.(googleapis/gapic-generator-typescript#853)
Fixes #1008 🦕