Using auth0-spa-js in an Angular 9 application results in a Typescript error during compilation.
When auth0-spa-js is used inside a new Angular 9 application, compilation fails with the following error:
ERROR in node_modules/@auth0/auth0-spa-js/dist/typings/index.d.ts:9:8 - error TS2440: Import declaration conflicts with local declaration of 'Auth0Client'.
9 import Auth0Client from './Auth0Client';
~~~~~~~~~~~
Imports are done this way:
import createAuth0Client from '@auth0/auth0-spa-js';
import Auth0Client from '@auth0/auth0-spa-js/dist/typings/Auth0Client';
Please provide the following:
Thanks @Arnaud73. You should be able to do:
import createAuth0Client, { Auth0Client } from '@auth0/auth0-spa-js';
To import that type - does that cause the error to go away, or does it remain?
Same issue for us, syntax above does not work. Our workaround is to set "skipLibCheck": true, in tsconfig.json. We import:
import createAuth0Client, { Auth0Client, GetTokenSilentlyOptions, LogoutOptions, RedirectLoginOptions } from '@auth0/auth0-spa-js';
Thanks @stevehobbsdev!
Bad luck, it does not change a thing. Same error :(
For additionnal information, my AuthService is quite similar to the one defined in your documentation (https://auth0.com/docs/quickstart/spa/angular2/01-login). I guess yours, if implemented in a brand new Angular 9 project, will raise the error.
Thanks @submarines-and, your workaround is working for me. I'm going to stick with "skipLibCheck": true until the package is fixed
I'm not sure we're able to fix this particular issue any time soon. The way it has been built so far doesn't play very nicely with mixed default and named exports, so unfortunately we need to get a little bit hacky with the type system. To fix this though will mean a breaking change. This is absolutely something we want to fix in the future when we release a new major version though, and the interface around importing these types will change.
Thanks for the tip @submarines-and, if you don't mind I will add this to the FAQ for reference in the future.
This should be resolved by #367 - which is in the latest beta
Can you give v1.7.0-beta.4 a try?
Seems to be working for me :)