fix: widen getTokenSilently overload return types to include undefined#1646
fix: widen getTokenSilently overload return types to include undefined#1646yogeshchoudhary147 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesToken return typing and fetcher validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Auth0Client.ts (1)
321-331: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winWiden
AccessTokenFactoryto includeundefined.getTokenSilently({ detailedResponse: true })returnsPromise<GetTokenSilentlyVerboseResponse | undefined>, butsrc/fetcher.tsstill requiresPromise<string | GetTokenSilentlyVerboseResponse>. WithstrictNullCheckson, bothgetAccessTokencallbacks insrc/Auth0Client.ts:323-331andsrc/Auth0Client.ts:2080-2085will fail type-checking unless the factory type or the callback handles theundefinedcase.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Auth0Client.ts` around lines 321 - 331, The getAccessToken callbacks in Auth0Client are returning a value from getTokenSilently(..., detailedResponse: true) that can also be undefined, but AccessTokenFactory in fetcher.ts still only allows string or GetTokenSilentlyVerboseResponse. Update the AccessTokenFactory type to include undefined, or handle the undefined case explicitly in the callbacks used by createFetcher and the other getAccessToken site in Auth0Client so the strictNullChecks type error is resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/Auth0Client.ts`:
- Around line 321-331: The getAccessToken callbacks in Auth0Client are returning
a value from getTokenSilently(..., detailedResponse: true) that can also be
undefined, but AccessTokenFactory in fetcher.ts still only allows string or
GetTokenSilentlyVerboseResponse. Update the AccessTokenFactory type to include
undefined, or handle the undefined case explicitly in the callbacks used by
createFetcher and the other getAccessToken site in Auth0Client so the
strictNullChecks type error is resolved.
405ea01 to
cb64496
Compare
cb64496 to
d556018
Compare
The public overloads for
getTokenSilentlydeclarePromise<string>andPromise<GetTokenSilentlyVerboseResponse>, but the implementation can returnundefinedin two cases:cacheMode: 'cache-only'with no matching cache entry — pre-existing behaviour; the overloads were already incorrect before IPSIE.session_expiryceiling reached — introduced when the session expiry ceiling feature was added.The implementation signature already reflects this (
Promise<undefined | string | GetTokenSilentlyVerboseResponse>), but overload signatures are what callers see — the implementation signature is invisible externally.This aligns the overloads with the implementation so consumers can write correct null checks without fighting the type system.