fix: cast to service options for the auth library - #9078
Conversation
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is actually a good point. We should try #9084 first to see if it resolves the problem.
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.