Skip to content

Typescript example of extending Parse.User #722

@GanymedeIndustries

Description

@GanymedeIndustries

Sorry firstly if this has been answered somewhere, but I cannot for the life of me figure out how to extend the Promise.User object. Below is an example of what I'm trying to do"

Parse.User.allowCustomUserClass(true);

export class User extends Parse.User {
  IsAdmin: boolean;

  constructor() {
    super('_User');
  }

  isThisUserAnAdmin(): boolean {
    return !(!this.get('IsAdmin'));
  }

  static signUpAsAdmin(email: string, password: string): Promise<User> {
    return Parse.User.signUp(email, password,
      {
        email: email,
        isAdmin: true
      }
    );
  }
}

Parse.Object.registerSubclass('User', User);

Obviously signUpAsAdmin won't work as it will return an instance of Parse.User and not User, but I can't find any clear example of extending Parse.User with an extra property in typescript (should I use typescript accessors?). Again, sorry if there is one, but my head is a bit buggered from looking. Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:docsOnly change in the docs or README

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions