# JS cannot resolve object

**URL:** <https://discuss.kotlinlang.org/t/js-cannot-resolve-object/8249>\
**Category:** JavaScript\
**Created:** [June 22, 2018, 10:52am UTC](https://discuss.kotlinlang.org/t/js-cannot-resolve-object/8249 "2018-06-22T10:52:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomschrot](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tomschrot/32/4346_2.png) [@tomschrot](https://discuss.kotlinlang.org/u/tomschrot)\
**Post date:** [June 22, 2018, 10:52am UTC](https://discuss.kotlinlang.org/t/js-cannot-resolve-object/8249/1 "2018-06-22T10:52:14Z")

</div>

Hi

in HTML I use

```
<button id="_bt1" type="button" onclick="kt.MyClass.Event.invoke(this)">

```

for signaling GUI events to Kotlin-JS. That will work for a class like

```
class MyEvent{
	@JsName("invoke")
    fun invoke(obj: dynamic) {}
}

class MyClass{
    object Event: MyEvent()
}

```

but moving Event to an e.g. abstract class like

```
abstract class Control{
    object Event: MyEvent()
}

class OtherClass: Control {
}

```

the JS runtime crashes with  
_Uncaught TypeError: Cannot read property ‘invoke’ of undefined_  
\_ at HTMLButtonElement.onclick\_

How can I solve this?

---

<div class="post-metadata">

**Author:** ![Konstantin-Khvan](https://avatars.discourse-cdn.com/v4/letter/k/4af34b/32.png) [@Konstantin-Khvan](https://discuss.kotlinlang.org/u/Konstantin-Khvan)\
**Post date:** [June 23, 2018, 12:46pm UTC](https://discuss.kotlinlang.org/t/js-cannot-resolve-object/8249/2 "2018-06-23T12:46:34Z")

</div>

Looks like you have declared new type Event and its instance in base abstract class but trying to invoke it from instance of inherited class. There is no OtherClass.Event only Control.Event.  
I would recommend using class properties for events, not objects.
