Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-2007

@realm/babel-plugin - function initializers are not working

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Realm Babel

      How frequently does the bug occur?

      All the time

      Description

      Given the following class

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      export class Task extends Realm.Object<Task> {
        _id: Realm.BSON.ObjectId = () => new Realm.BSON.ObjectId();
        description!: string;
        isComplete: boolean = false;
        createdAt: Date = new Date();
        someField: string = () => {
          const date = new Date();
          return date.toString();
        };
        userId!: string;
      
        static primaryKey = '_id';
      
        constructor(realm: Realm, description: string, userId?: string) {
          super(realm, {description, userId: userId || '_SYNC_DISABLED_'});
        }
      }
      

      It is expected that the functional initializers for the fields would populate the default field for that type in the generated realm schema. Right now, this syntax results in both a runtime and typescript error:

      • runtime:
      • typescript:

      Stacktrace & log output

      No response

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      Use the example application in the realm project and attempt to declare and use functional initializers.

      Version

      11 and above

      What SDK flavour are you using?

      Atlas App Services (auth, functions, etc.)

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      Platform Independent

      Build environment

      Which debugger for React Native: ..

      Cocoapods version

      No response

            Assignee:
            Unassigned Unassigned
            Reporter:
            andrew.meyer@mongodb.com Andrew Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: