Skip to content
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
alicejli:warn
May 24, 2021
Merged

feat: add type parameter to warn function#1009
alicejli merged 8 commits intogoogleapis:masterfrom
alicejli:warn

Conversation

@alicejli
Copy link
Contributor

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 🦕

@alicejli alicejli requested a review from a team as a code owner May 19, 2021 21:00
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label May 19, 2021
Copy link
Contributor

@summer-ji-eng summer-ji-eng left a 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

@alicejli alicejli changed the title Add type parameter to warn function feat: add type parameter to warn function May 19, 2021
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.)
Copy link
Contributor

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
Comment on lines +32 to +36
if (type !== 'undefined') {
process.emitWarning(message, type);
} else {
process.emitWarning(message);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@summer-ji-eng summer-ji-eng left a 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
console.warn(message);
} else {
process.emitWarning(message);
if (typeof warnType !== 'undefined') {
Copy link
Contributor

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 :)

@alicejli alicejli merged commit fef2e7c into googleapis:master May 24, 2021
@alicejli alicejli deleted the warn branch May 24, 2021 23:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 'type' parameter to 'warnings.ts'

3 participants