Is it possible to expose a swift class to JavascriptCore using JSExport and add a javascript subclass? I'm getting this weird behavior:
swift:
@objc protocol Person {
init()
func sayHi()
}
class PersonProxy: NSObject, Person {
required override init() {
super.init()
}
func sayHi() {
print("hi")
}
}
jsContext?.setObject(PersonProxy.self, forKeyedSubscript: "Person" as (NSCopying & NSObjectProtocol)!)
javascript:
class Employee extends Person {
constructor() {
super()
}
sayHello() {
console.log("hello")
}
}
var test = new Employee()
console.log("Is Employee: " + (test instanceof Employee)) // this prints "Is Employee: false"
test.sayHello() // this gives me "JS Exception: TypeError: test.sayHello is not a function"