You can use the built-in Source Actions for generating serializing and deserializing functions for your costum structured types (https://docs.industrial-operations-x.siemens.cloud/r/en-us/ax-vscode/siemens.st-lang/3.5.58/structured-text-language-extension/source-actions/generating-serialization-functions).
This deals with the limitation that the system function only takes in elementary data types.
Thanks for your answer!
I know about the generation of these serialization functions, but I was wondering if a TIA-like serialize function that can take a VARIANT dt will ever come to AX.
The generator, for example, serializes BOOL datatypes to their own BYTE instead of packing multiple into a WORD or BYTE.