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

bug(): catch spools declarations that are not classes #33

Open
scott-wyatt opened this issue Jan 23, 2019 · 0 comments
Open

bug(): catch spools declarations that are not classes #33

scott-wyatt opened this issue Jan 23, 2019 · 0 comments
Labels
backward-compatibility bug Something isn't working

Comments

@scott-wyatt
Copy link
Contributor

scott-wyatt commented Jan 23, 2019

Attached is a possible script implementation to check if a spool is actually a class. This helps pure JS users more than TS users, but, since it all runs in JavaScript at the end of the day, it makes sense to do an explicit check.

export default fn => {
  if (typeof fn != "function") {
    return false
  }

  let proxy = new Proxy(fn, {
    construct: () => fn,
  })

  try {
    new proxy
  } catch {
    return false
  }

  return true
}

Additionally, with babel constructing things down to es5 for browsers, it would be helpful to detect if the spool is es5 or es6 already.

@scott-wyatt scott-wyatt changed the title Catch spools declarations that are not classes bug(): catch spools declarations that are not classes Oct 14, 2019
@scott-wyatt scott-wyatt added the bug Something isn't working label Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backward-compatibility bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant