# How to check if arbitrary object type is an Image

**URL:** https://forum.makecode.com/t/how-to-check-if-arbitrary-object-type-is-an-image/37926
**Category:** Help
**Created:** [July 7, 2025, 11:25pm UTC](https://forum.makecode.com/t/how-to-check-if-arbitrary-object-type-is-an-image/37926 "2025-07-07T23:25:51Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [July 22, 2025, 10:58pm UTC](https://forum.makecode.com/t/how-to-check-if-arbitrary-object-type-is-an-image/37926/5 "2025-07-22T22:58:56Z")

</div>

Try this as a workaround:

> [@Why doesnt this work expressionless](https://forum.makecode.com/t/why-doesnt-this-work/12991/3):
>
> Interesting, @hasanchik . Image is an interface, not a class, and instanceof does not work with interfaces in TypeScript. The traditional way to deal with this is to typecast the variable and check for an interesting method. That, though, does not work in MakeCode. [image] So, the next best thing is to check for an interesting attribute instead. This works: let a: Image = img`.` let b: number = 42 let msg: string = "" function testImage(i: any): boolean { if ((\<Image\>i).width) { …

---

_[View the full topic](https://forum.makecode.com/t/how-to-check-if-arbitrary-object-type-is-an-image/37926)._
