Auth0 Home Blog Docs

How to use auth0 spa with TypeScript?

I’m implementing Auth0 in a React TypeScript site and am trying to get the https://auth0.com/docs/quickstart/spa/react to work.

Specifically, when the react-auth0-wrapper.js is converted to react-auth0-wrapper.tsx I get TS errors on the following lines.

const loginWithPopup = async () => {
const handleRedirectCallback = async () => {

An async function or method in ES5/ES3 requires the Promise constructor. Make sure you have a declaration for the Promise constructor or include ES2015 in your --lib option.

The lib option of tsconfig.json looks like this

"lib": [
  "dom",
  "dom.iterable",
  "esnext"
],

Any thoughts or insights appreciated.

Hi there @treasurer and welcome to the Auth0 Community!

I will dive into this, give it a build, and let you know what I find :+1: Thanks!

Hi @James.Morrison, any update on that front, I’d be interested to use the wrapper in typescript as well.

Thanks

Still investigating on this front, will share details as they emerge.