Giter Site home page Giter Site logo

Comments (3)

uittorio avatar uittorio commented on May 17, 2024

To implement this feature we would have to merge two different mocks.
Any merge functionality will have to check if a field exist into an object. This will cause trigger getters of our internal mock. If the getter is a reference to a mock that has recursion it will cause Maximum call stack.

Feel free to close the issue if you are happy with the conclusion

Example

interface A {
 mySelf: A
}

interface B extends A {
   bProperty: string;
}

repository.register('A', (function(){
  var __mySelf;
  return {
      get mySelf() { return __mySelf || (__mySelf = repository.get('A')) },
      set mySelf(_mySelf) { mySelf= _mySelf}
    },
  );
}))

repository.register('B', (function(){
  var __bProperty;
  var mock;

  mock = {
      get bProperty() { return __bProperty || (__bProperty = '') },
      set bProperty(_bProperty) { bProperty = _bProperty }
  };
  // this will cause the error because property mySelf of A is recursive
  return  mergeFunctionality(mock, repository.get('A')) 
  );
}))

from ts-auto-mock.

Pmyl avatar Pmyl commented on May 17, 2024

I have another idea to solve this that won't trigger the getters, let's keep this open at low priority right now

from ts-auto-mock.

Pmyl avatar Pmyl commented on May 17, 2024

@uittorio I still have an idea on how to do it but I think it's not worth it from every angle.
Not worth it because other features are definitely more important.
Not worth it because it doesn't really improve performance.
Not worth it because it will probably affect the performance negatively (in my solution I would trade lines of code for run time).

I'm closing this, if we actually see people having performance issues with this then we can reopen it.

from ts-auto-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.