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

Importing JS that uses instanceof doesn't work. #583

Closed
ccorcos opened this issue May 3, 2018 · 1 comment
Closed

Importing JS that uses instanceof doesn't work. #583

ccorcos opened this issue May 3, 2018 · 1 comment
Labels

Comments

@ccorcos
Copy link

ccorcos commented May 3, 2018

Create a file test.js. Yes, a javascript file. This is to simulate using an external library.

module.exports = {
	isArray: function(x) {
		return x instanceof Array
	},
}

Now open up the REPL and try to use it:

$ ./node_modules/.bin/ts-node
> import * as t from "./test"
{}
> t.isArray([])
false

Took me a while to track this down and caused a lot of confusion!

@blakeembrey
Copy link
Member

Looks like it's only from the REPL and related to context somehow, I'll have to see how node.js is using the REPL here and why imports are in a different context to the regular REPL.

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

No branches or pull requests

2 participants