Is there a super type for all class instances besides "any"?

I am implementing an interface with a method that looks like:

Update(Payload: any): void

I would like to type cast the payload to different types and depending on if the type cast succeeds, take some sort of action.

However, I’m hitting the error: “dynamic cast argument type ‘any’ must be a class”.

It seems like dynamic type casting is only supported for class instances. Is there a way to type my Payload parameter to signify that it is guaranteed to be a class?

Doing generic code can be quite annoying in Verse right now, the any type is almost useless, I don’t try to use it anymore.

But you might have other possibilities depending on what you want to achieve exactly.

You could use parametric functions and/or classes for example :person_shrugging:

1 Like

Yeah I thought about making a generic base class for all of my custom classes, but just feels bad haha. Plenty of workarounds, just wish that some of these language features were more flexible

Yes I agree, but I think that it will be improved one day, as they say it themselves that this type lacks uses (c.f. doc)

There is very little that you can do with an any type. but it’s good to be aware of this type as it may come up when writing code that produces an error.