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

Support Module Augmentation in TypeScript #207

Open
nip10 opened this issue Mar 31, 2023 · 0 comments
Open

Support Module Augmentation in TypeScript #207

nip10 opened this issue Mar 31, 2023 · 0 comments

Comments

@nip10
Copy link

nip10 commented Mar 31, 2023

This is a feature request for module augmentation using TypeScript.

When you add custom properties to the access token payload in the backend via createNewSession override, you lose type safety in the front-end when accessing the payload object.

A sortof work-around is to do something like

interface AccessTokenPayload {
  extraProperty: string
}

const accessTokenPayload: AccessTokenPayload = await session.getAccessTokenPayloadSecurely()

It would be nice to have a way to tell TypeScript the content of the payload in a more global way, like next-auth does

import { AccessTokenPayload } from "super-tokens/foo/bar"

declare module "super-tokens/foo/bar" {
  interface AccessTokenPayload {
    address?: string;
	postalCode: number;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant