Coder Social home page Coder Social logo

@returns(Self) ? about decoratethis HOT 6 CLOSED

mako-taco avatar mako-taco commented on May 18, 2024
@returns(Self) ?

from decoratethis.

Comments (6)

mako-taco avatar mako-taco commented on May 18, 2024

what do you think of having the decorator handling the return (as opposed to just checking it)?

class T {
  @chainable
  add(number) {
    this.total += number;
  }
}

from decoratethis.

callumlocke avatar callumlocke commented on May 18, 2024

Interesting. I guess so, why not

from decoratethis.

callumlocke avatar callumlocke commented on May 18, 2024

Actually, I've been thinking about this, and here is an opinion... Having a decorator called chainable feels like a small piece of automation that doesn't actually add much value (it's just as easy and more explicit to return this). And it feels like it's straying from the 'type-checking' purpose of this library. In fact, I think you should consider refocusing the whole library so it's not just a "mixed bag" of decorators, and instead it's purely decorators for adding type-checking to JS. In other words, get rid of "debounce", "curry" etc. (or put them in a separate lib). And change the name to something like "type-decorators" or "strict-type". The library is already 90% about type-checking anyway, and I think it might have more appeal if it was completely focused on it. You may disagree though.

from decoratethis.

callumlocke avatar callumlocke commented on May 18, 2024

did you mean to close this?

from decoratethis.

mako-taco avatar mako-taco commented on May 18, 2024

yeah, wont be adding it

from decoratethis.

callumlocke avatar callumlocke commented on May 18, 2024

any particular reason? do you have another way for verifying that a method returns this?

from decoratethis.

Related Issues (11)

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.