auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

remove redundant `getSession` type

Open curiosbasant opened this issue 1 year ago • 0 comments

What kind of change does this PR introduce?

A fix for the getSession return type.

What is the current behavior?

It was difficult to use the following utility function:

async function withThrowOnError<T>(
  promise: Promise<{ data: T; error: null } | { data: unknown; error: Error }>,
): Promise<T> {
  const { data, error } = await promise;
  if (error) throw error;
  return data;
}

withThrowOnError(supabase.auth.getSession()); // Type `null` is not assignable to type `Session`.

What is the new behavior?

It conveniently fixes the type error without breaking anything.

curiosbasant avatar Jun 26 '24 21:06 curiosbasant