Code Monkey home page Code Monkey logo

typescript-mix's People

Contributors

michaelolof avatar nioperas06 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

typescript-mix's Issues

This expression is not callable.

ERROR in D:/git/aca-stages/src/components/InternshipsSchedule.vue(994,4):
994:4 This expression is not callable.
  Type 'typeof import("D:/git/aca-stages/node_modules/typescript-mix/dist/index")' has no call signatures.
    992 | })
    993 | export default class InternshipsSchedule extends Vue {
  > 994 |   @use( stepsMixin ) (this as any)
        |    ^
    995 | 
    996 |   dataLevelsIsLoading = false
    997 | 
Version: typescript 3.9.7
Time: 780ms

[ts] Member 'this' implicitly has an 'any' type

When I use code from the example it throws me an error on this statement: [ts] Member 'this' implicitly has an 'any' type

class Shopperholic {
    @use( Buyer, Transportable ) this
    
    price = 2000;
    distance = 140;
  }

I have made the "noImplicitAny": false in tsconfig and all is ok but wonder - is it a valid behaviour?

@use() decorator on class

I think it would kind off make more sense for the @use decorator to be applied on classes instead of a property 'this:any'.

So for example:

class Mixable {}

@use(Mixable)
class Mixed {}

interface Mixed extends Mixable {}

Usage without decorators?

This looks really cool! Can I use this without decorators? I'm using sucrase for fast builds, but it doesn't support decorators (since it's not fully standardized).

Mixins don't work with getters

I just started using this library today. I love it so far. Thanks for maintaining it.

From what I can tell, typescript getters don't work with mixins (at least in my specific case). Here is an example I am trying to get to work.

class EmployableMixin {
  config: any;
  get companyId(): string {
    return this.config.companyId; // TypeError: Cannot read property 'companyId' of undefined
  }
}

class Employee {
  @use(EmployableMixin)

  config: any;
  constructor(config) {
    this.config = config;
  }
}

const employee = new Employee({companyId: '12345'});
console.log(employee.companyId) // error

However, if I edit the mixin to use a regular function rather than a getter, the error goes away:

class EmployableMixin {
  config: any;
  getCompanyId(): string {
    return this.config.companyId; // no error
  }
}

class Employee {
  @use(EmployableMixin)

  config: any;
  constructor(config) {
    this.config = config;
  }
}

const employee = new Employee({companyId: '12345'});
console.log(employee.getCompanyId()) // 12345

I realize I'm probably doing something unconventional by trying to access the config object in the mixin class. But if it works with a regular function I feel like it should work with a getter as well. Do you know if this would be possible to fix? I'm happy to help out with a pull request. I just wanted to get your thoughts first.

booleans?

Any reason we can't mixin boolean properties? Thanks!

p.s. Great library - the best I've found for TypeScript that has Intellisense working nicely!

Suggestion - not a bug - Is it possible to add testing examples for this library?

Great work here, very simple intuitive API.

I read on your medium article that it would be easy to test mixins to by instantiating them.

Would you be able to push any examples tests inside an example folder in this repo, or would you be able to share a code-snippet as it would be very useful.

I hope to share your work with others and introduce them to this great concept.

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.