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

Typescript example of extending Parse.User #722

Closed
GanymedeIndustries opened this issue Jan 31, 2019 · 2 comments
Closed

Typescript example of extending Parse.User #722

GanymedeIndustries opened this issue Jan 31, 2019 · 2 comments
Labels
type:docs Only change in the docs or README

Comments

@GanymedeIndustries
Copy link

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

@fmendoza
Copy link

See my workaround

@dplewis
Copy link
Member

dplewis commented Mar 21, 2019

Closing via parse-community/docs#606

@dplewis dplewis closed this as completed Mar 21, 2019
@dplewis dplewis added type:docs Only change in the docs or README pr-submitted labels Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Only change in the docs or README
Projects
None yet
Development

No branches or pull requests

3 participants