Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance instanceof mixin? #17

Open
CoryGH opened this issue Oct 5, 2016 · 4 comments
Open

instance instanceof mixin? #17

CoryGH opened this issue Oct 5, 2016 · 4 comments

Comments

@CoryGH
Copy link

CoryGH commented Oct 5, 2016

Is there a way to do something like:

let MyMixin = Mixin((superclass) => class extends superclass {
    constructor() {
        super(...arguments);
    }
});
class MyClass extends mix(Array).with(MyMixin) {
    constructor() {
        super();
    }
}
var a = new MyClass();
console.log(a instanceof Array);
console.log(a instanceof MyClass);
console.log(a instanceof MyMixin);

Where the result would be:

true
true
true

Currently it returns:

true
true
Uncaught TypeError: Function has non-object prototype 'undefined' in instanceof check
@minecrawler
Copy link

I cannot confirm your bug. I just tested it with

  • mixwith v0.1.1 (NPM version)
  • NodeJS v6.9.1

on Windows 7 x64

The test code file being:

'use strict';

const mx = require('mixwith');


let MyMixin = mx.Mixin((superclass) => class extends superclass {

    constructor() {
        super(...arguments);
    }
});

class MyClass extends mx.mix(Array).with(MyMixin) {
    constructor() {
        super();
    }
}

var a = new MyClass();

console.log(a instanceof Array);
console.log(a instanceof MyClass);

console.log(a instanceof MyMixin);

with the console output:

"C:\Program Files (x86)\JetBrains\WebStorm 2016.2.1\bin\runnerw.exe" "C:\Program Files\NodeJS\node.exe" --debug-brk=46896 --expose_debug_as=v8debug C:\Users\marco_000\Documents\tmp\mixins.js
Debugger listening on [::]:46896
true
true
true

@Uxspy
Copy link

Uxspy commented Jan 24, 2018

I'm using node v6.9.1 (npm v3.10.8) and got the same error:
TypeError: Function has non-object prototype 'undefined' in instanceof check

@cryonics84
Copy link

I get same error

@Yiin
Copy link

Yiin commented Jul 3, 2022

It's because you need to wrap your mixins with Mixin function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants