The type function returns 'Object' for ES6 method shorthand when running in an environment where that ES6 isn't transpiled. It's technically correct, but 'Function' seems like it would be more appropriate. This also makes isType and isFunction return unexpected results.
const obj = {
f(){
return 4;
}
};
type(obj.f); // => 'Object'
typeof obj.f; // => 'function'
It may also be worth considering that it produces the same result for computed property shorthand:
const name = 'f';
const obj = {
[name](){
return 4;
}
};
type(obj.f); // => 'Object'
typeof obj.f; // => 'function'
The
typefunction returns'Object'for ES6 method shorthand when running in an environment where that ES6 isn't transpiled. It's technically correct, but'Function'seems like it would be more appropriate. This also makesisTypeandisFunctionreturn unexpected results.It may also be worth considering that it produces the same result for computed property shorthand: