• I'm getting the error in the subject. The code is

    IndexedCollection.__proto__ = Collection;
    

    and yes, Collection is function. But also an Object.

    Do I need to transpile this or something else?

  • Please can you come up with a very minimal code example that works on its own that I can use to test with?

    It's possible it's just an overzealous check

  • The piece of code below reproduces the error. The weird part is that if you comment out the line where proto is assigned in one (regardless which) of the two constructors you don't get the error. This does not make sense to me.

    var Collection = function Collection(value) {
      return value;
    };
    
    var KeyedCollection = /*@__PURE__*/ (function (Collection) {
      function KeyedCollection(value) {
        //return isKeyed(value) ? value : KeyedSeq(value);
      }
    
      if (Collection) KeyedCollection.__proto__ = Collection;
      KeyedCollection.prototype = Object.create(Collection && Collection.prototype);
      KeyedCollection.prototype.constructor = KeyedCollection;
    
      return KeyedCollection;
    })(Collection);
    
    var IndexedCollection = /*@__PURE__*/ (function (Collection) {
      function IndexedCollection(value) {
        //return isIndexed(value) ? value : IndexedSeq(value);
      }
    
      if (Collection) IndexedCollection.__proto__ = Collection;
      IndexedCollection.prototype = Object.create(Collection && Collection.prototype);
      IndexedCollection.prototype.constructor = IndexedCollection;
    
      return IndexedCollection;
    })(Collection);
    
    
  • It's just a check in the interpreter when proto is assigned (because it's an internal variable). Just fixed it - so latest builds will work now

  • Using espruino_2v11.30_esp32.bin this error is gone. Thanks!
    However I managed to load the module once with different error but after that I only get | New interpreter error: LOW_MEMORY,MEMORY when requiring the module. I store it on the storage. The file is 64k, I have 4M ram.

    In case you are wondering — I'm trying to upload the immutable.js library as sort of stress test. Want to see if it's feasible to use most of my regular JS toolbox.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Uncaught TypeError: Prototype should be an object, got Function

Posted by Avatar for gdanov @gdanov

Actions