Hi, I have this error âArgument of type âtypeof SectionLevelâ is not assignable to parameter of type âConstructor | TypeResolver | (Constructor | TypeResolver) | null | undefinedâ.â in this script
Hello there â we have an experimental AI bot that might be able to help you with your question. Would you like to try this out?
How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.
Hello Maxi Brunetti, it appears you have encountered a TypeScript error related to the use of decorators with enum types in your UISections class. Enums are a special case when it comes to serialization in TypeScript.
As per the Needle Engine documentation, the @serializable() decorator is used to deserialize components when loading a scene from a glTF, and it takes optionally the type which should be deserialized. However, in the case of enums, itâs not straightforward to use them with decorators as they do not result in a type that can be instantiated like a class.
To resolve this, you donât need to pass the enum type to the @serializable() decorator. Instead, use it without any arguments for primitive values like enums. Enums are serialized as their numeric values by default in TypeScript.
Make sure the enum is declared before itâs used in the class to avoid any reference errors, and apply the @serializable() decorator without passing the enum type as a parameter. If you require a different serialization method for the enum, you might need to implement custom serialization logic.