supertokens-website
supertokens-website copied to clipboard
Support Module Augmentation in TypeScript
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;
}
}