Skip to content

Unable to extend Error when targeting es5 with TS 2.1 #12058

Closed
@asvetliakov

Description

@asvetliakov

TypeScript Version: 2.1.0-dev.20161104

Code
tsconfig.json

{                       
  "compilerOptions": {  
    "target": "es5",    
    "module": "commonjs"
  }      
}                       
// A *self-contained* demonstration of the problem follows...
class Test extends Error {
        constructor(message: string) {
                super(message);
        }
}

const test = new Test("test");

console.log(`Instance of error: ${test instanceof Error}`);
console.log(`Instance of test: ${test instanceof Test}`);

Expected behavior:

Instance of error: true
Instance of test: true

Actual behavior:

Instance of error: true
Instance of test: false

It works with TS 2.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions