Skip to content

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

@scott-wyatt

Description

@scott-wyatt

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions