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

an object of The class which is extends by base type like Array,Number,Object,String or Error is not instanceof this class #5496

Closed
wm123450405 opened this issue Mar 18, 2017 · 2 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@wm123450405
Copy link

wm123450405 commented Mar 18, 2017

index.js

class Exception extends Object { //Array, Number, String, Function, Error, RegExp, Boolean all of base type has this program
	constructor() {
		super('Exception');
	}
}
module.exports = Exception;

gulpfile.js

const gulp = require('gulp');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');

gulp.task('default', () => {
	browserify({
			entries: "./index.js",
			standalone: 'Exception',
			debug: true
		})
		.transform(babelify.configure({
			presets: ["es2015", "stage-3"],
			sourceMaps: true
		}))
		.bundle()
		.pipe(source('index.js'))
		.pipe(buffer())
		.pipe(gulp.dest('./dest'));
});

test.js

const Exception = require('./dest/index');

console.log(new Exception() instanceof Exception);

the result is false

new Exception() is not instanceof Exception, but only instanceof Error

@babel-bot
Copy link
Collaborator

Hey @wm123450405! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@wm123450405 wm123450405 changed the title an object of The class which is extends by Error is not instanceof this class an object of The class which is extends by base type like Array,Number,Object,String or Error is not instanceof this class Mar 18, 2017
@hzoo
Copy link
Member

hzoo commented Mar 18, 2017

We don't support extending built-ins yet: http://babeljs.io/docs/usage/caveats/#classes but we are trying to figure out a solution. #4480

@hzoo hzoo closed this as completed Mar 18, 2017
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 5, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants