Implicit return in auth0-spa-js/src/cache /cache-manager.ts when TS "noImplicitReturns" is set to true
Checklist
- [X] The issue can be reproduced in the auth0-spa-js sample app (or N/A).
- [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [X] I have looked into the documentation and API documentation, and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
private async getCacheKeys(): Promise<string[] | undefined> { if (this.keyManifest) { return (await this.keyManifest.get())?.keys; } else if (this.cache.allKeys) { return this.cache.allKeys(); } }
Reproduction
Install Auth0 library
-
npm i --save @auth0/auth0-spa-js
-
Make use of it
-
npm run build the angular project
✘ [ERROR] TS7030: Not all code paths return a value. [plugin angular-compiler]
../../node_modules/@auth0/auth0-spa-js/src/cache/cache-manager.ts:156:32:
156 │ private async getCacheKeys(): Promise<string[] | undefined> {
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additional context
No response
auth0-spa-js version
2.1.3
Which framework are you using (React, Angular, Vue...)?
Angular
Framework version
17
Which browsers have you tested in?
Other
Hello @denniscalazans ,
I am not seeing the error you mentioned when I use [email protected] along with [email protected]. Can you share your package.json here ?
Additionally, could you provide a code snippet demonstrating how you are using [email protected] ?. This would be helpful.
I'm having the same problem. We've implemented our own ICache, and configured that in Auth0.config.cache. That seems to cause it, reverting back and using the default 'memory' or 'localstorage' option does not cause this error to occur.
I've set "noImplicitReturns": false in our own tsconfig.json to fix this but that is less than ideal
Was caused by a direct import from @auth0/auth0-spa-js/src/cache/shared instead of @auth0/auth0-spa-js in our repo.
The MaybePromise return type is not re-exported by @auth0/auth0-angular, so that might be why some people are running into this problem when implementing their own Cache. I think some editors will attempt to directly import that type from @auth0/auth0-spa-js/src/cache/shared when @auth0/auth0-spa-js is not in the package.json, because it is a dependency of @auth0/auth0-angular.