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

Errors subclasses instances are replaced by base Error #889

Closed
ntrrgc opened this issue Dec 1, 2016 · 1 comment
Closed

Errors subclasses instances are replaced by base Error #889

ntrrgc opened this issue Dec 1, 2016 · 1 comment

Comments

@ntrrgc
Copy link

ntrrgc commented Dec 1, 2016

Issue description or question

I run a series of test I wrote a long time ago and suddenly two of them were failing... After running several experiments I found Wallaby is changing the semantics of this:

class MyError extends Error {
    myMethod() {
        return "meow";
    }
}

console.log(new MyError() instanceof MyError);
console.log(new MyError().myMethod);

Running the previous code in a browser returns this, as expected:

true
function myMethod() {
        return "meow";
    }

But running it in Wallaby returns something not expected at all:

false
undefined

Wallaby.js configuration file

module.exports = (w) => {
    return {
        files: [
            "src/**/*.ts"
        ],
        tests: [
            "spec/**.spec.ts"
        ],
        compilers: {
            "**/*.ts": w.compilers.typeScript({module: "commonjs"}),
        },
        debug: true,
        env: {
            type: "node"
        },
        testFramework: "mocha",
        setup: function (wallaby) {
            require("bluebird").config({
                longStackTraces: true
            })
        }
    }
}

Code editor or IDE name and version

PHPStorm 2016.3

OS name and version

Arch Linux

@ArtemGovorov
Copy link
Member

Interesting one.

This issue is not wallaby.js specific, but TypeScript compiler version specific (same happens with Babel BTW). You may try compiling the code with ./node_modules/.bin/tsc, running it in node and you'll get the same result.

Have a look into:
microsoft/TypeScript#12123
microsoft/TypeScript#12058
microsoft/TypeScript#12145
microsoft/TypeScript#12581
microsoft/TypeScript#10166
microsoft/TypeScript#12279

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

2 participants