Skip to content

fix: cast to service options for the auth library - #9078

Open
danieljbruce wants to merge 1 commit into
mainfrom
node-22-resolve-auth-compiler-error-2
Open

fix: cast to service options for the auth library#9078
danieljbruce wants to merge 1 commit into
mainfrom
node-22-resolve-auth-compiler-error-2

Conversation

@danieljbruce

Copy link
Copy Markdown
Contributor

Description

Upgrading the auth library causes a compiler error which we address with a cast. It won't affect how the code works and the compiler error looks like it was just caused by a difference in autogeneration where one interface property marks the auth client as optional as indicated by the Type 'AuthClient' is not assignable to type 'AuthClient | GoogleAuth<AuthClient> | undefined'. line in the console. This is unlikely to indicate a problem with upgrading the auth dependency.

Impact

Completes the auth dependency upgrade

Additional Information

Although the change is in the generated library section and ideally we don't make manual changes there, if the change gets overwritten then our CI pipeline will tell us immediately by reporting a compiler error. Therefore, it is fine if we upgrade the dependency now in order to ensure all Node dependencies are on version 22.

@danieljbruce
danieljbruce requested a review from a team as a code owner August 4, 2026 14:14
@danieljbruce
danieljbruce requested a review from westarle August 4, 2026 14:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the google-auth-library dependency to version ^11.0.0 and adds a type cast to ServiceOptions in packages/google-cloud-translate/src/v2/index.ts to resolve a type mismatch. The reviewer notes that using a type cast bypasses TypeScript compiler checks instead of addressing the root cause. They recommend aligning the google-auth-library dependency versions across the packages or updating @google-cloud/common to support version 11 directly.

};

super(config, options);
super(config, options as ServiceOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Casting options to ServiceOptions bypasses the TypeScript compiler check but does not address the root cause of the type mismatch. This issue typically arises because @google-cloud/common and google-cloud-translate are resolving different, incompatible versions of google-auth-library (v10 vs v11), leading to incompatible GoogleAuth or AuthClient types. Instead of using a type cast, we should align the google-auth-library dependency versions across the monorepo/packages, or update @google-cloud/common to support google-auth-library v11 so that the types are compatible naturally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually a good point. We should try #9084 first to see if it resolves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant