Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SvelteKit "User Management App" Docs - safeGetSession typescript error #26280

Open
justinburrow opened this issue May 14, 2024 · 0 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@justinburrow
Copy link

Improve documentation

Link

Add a link to the page which needs improvement (if relevant)
Build a User Management App with SvelteKit

Describe the problem

In the section related to adding types to 'app.d.ts' in order to correct typescript compiler errors, using what is provided will create another error in a different document:

// src/app.d.ts

import { SupabaseClient, Session } from '@supabase/supabase-js'

declare global {
  namespace App {
    interface Locals {
      supabase: SupabaseClient
      safeGetSession(): Promise<{ session: Session | null; user: User | null }>
    }
    interface PageData {
      session: Session | null
      user: User | null
    }
    // interface Error {}
    // interface Platform {}
  }
} 

Following the next steps, +layout.ts will have the compiler complaining because the returned objects will not have the user property that is specified in this type declaration for safeGetSession().

Describe the improvement

Mark the 'user' property with a question mark to indicate that it is an optional property in the return type.

    interface PageData {
      session: Session | null
      user?: User | null
    }

Additional context

Screenshot of page where the issue occurs:

Screenshot 2024-05-13 at 6 40 47 PM

@justinburrow justinburrow added the documentation Improvements or additions to documentation label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant