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

Type of async function should be function #4083

Closed
jcubic opened this Issue May 21, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@jcubic

jcubic commented May 21, 2018

async function fn() {}
var pre = $('pre');
pre.html([
  $.type(fn),
  $.isFunction(fn),
  typeof fn
].join('\n'));

first function return "object" second false and in comparison typeof return "function".

Here is demo (jsfiddle and jsbin throw error on async function)

https://codepen.io/jcubic/pen/vjbzYp?editors=0010

Tested in lastest Google Chrome/Firefox on windows and Chromium/Firefox on Linux. I've used version 3.1.1.

@jcubic

This comment has been minimized.

jcubic commented May 21, 2018

the same probably should be applied to generators for which $.type also return "object".

@jcubic

This comment has been minimized.

jcubic commented May 21, 2018

Before this is fixed the solution is:

const type = typeof object == 'function' ? 'function' : $.type(object);
@timmywil

This comment has been minimized.

Member

timmywil commented May 21, 2018

isFunction has already been changed on master and returns true. However, $.type could be changed and map AsyncFunction to function in our class2type mapping.

@dmethvin

This comment has been minimized.

Member

dmethvin commented May 21, 2018

Definitely want that for consistency I'd think.

@dmethvin

This comment has been minimized.

Member

dmethvin commented May 21, 2018

@jcubic would you like to submit a pull request?

@dmethvin

This comment has been minimized.

Member

dmethvin commented May 21, 2018

Actually we just discussed in our weekly meeting. jQuery.type() is being deprecated because there are better ways to determine that information using plain old JavaScript. We would either need to create a new return value for async functions or map async functions into plain functions, neither of which are good ideas.

@dmethvin dmethvin closed this May 21, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Nov 17, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.