I've been using babel on a few projects, and on my last project I got myself with this question;
I have a scan function where I want to set 2 default values
export default function scan({
tmpFolder = "./tmp",
verbose = false
}){
// function body
}
When importing the module into my bin project I have to set an empty {}
as param
var scan = require('scan');
scan({})
Otherwise, if I dont set it;
var scan = require('scan');
scan()
i'm getting an error;
var _ref$tmpFolder = _ref.tmpFolder;
^
TypeError: Cannot read property 'tmpFolder' of undefined
Why am I getting an error if I don't set an empty {}
? Shouldnt be {tmpFolder = "./tmp",verbose = false}
the default value ? Is this a Babel issue or is it wrong to don't set an empty {}
in this case ?
This is what I was looking for:
And then use
scan()
Thanks @loganfsmyth