regenerator icon indicating copy to clipboard operation
regenerator copied to clipboard

AsyncFunction is not an AsyncFunction

Open bertho-zero opened this issue 3 years ago • 0 comments

I haven't seen any mention of AsyncFunction in regenerator, are there any plans to create a polyfill or something like that?

https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction

The following code works in the Chrome console but not with a babelified code, the result of instanceof is always true:

const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;

async function asyncMethod() {}
function method() {}

console.log(asyncMethod instanceof AsyncFunction) // true
console.log(method instanceof AsyncFunction) // false, but true with babelified code

console.log(asyncMethod.constructor.name) // should be "AsyncFunction", but "Function" with babelified code

I don't know if this is the role of regenerator or babel, here is the corresponding issue on the babel repo: https://github.com/babel/babel/issues/8642

bertho-zero avatar Apr 09 '21 10:04 bertho-zero

What's more, there's some example code in README.md where it appears that location is being passed a specific prop name, but that doesn't match what checkPropTypes seems to do in actuality:

const myPropTypes = {
  name: PropTypes.string,
  age: PropTypes.number,
  // ... define your prop validations
};

const props = {
  name: 'hello', // is valid
  age: 'world', // not valid
};

// Let's say your component is called 'MyComponent'

// Works with standalone PropTypes
PropTypes.checkPropTypes(myPropTypes, props, 'age', 'MyComponent');
// This will warn as follows:
// Warning: Failed prop type: Invalid prop `age` of type `string` supplied to
// `MyComponent`, expected `number`.

DullReferenceException avatar Jun 24 '19 21:06 DullReferenceException