Skip to content

UserSession cannot be type-safe #433

@Vap0r1ze

Description

@Vap0r1ze

After trying to fix #422 on my project, I found out that the UserSession interface has a [x: string]: unknown index signature which basically removes all type information from the interface.

Even in this repo's playground, it has strict typing for UserSession, nor does it have intellisense / autocomplete

auth.d.ts is merged with ./runtime/types type merge successful
but no intellisense no intellisense
and no type safety no type safety

The only non-breaking solution I can think of for this is:

  • Provide an off-switch for this in the module's config
  • Move the [x: string]: unknown index signature from runtime/types/session.ts to an optional runtime/types/extra-session-keys.d.ts that adds the signature by extending '#auth-utils' like a user-land auth.d.ts would
  • Add runtime/types/extra-session-keys.d.ts with addTypeTemplate(..., { nuxt: true, nitro: true }) unless the off-switch config is set to false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions