I am currently building a form generation library that auto-generates code for both the client and server for use on websites. I have managed to successfully parse a simple text file into what’s called CField's and from here can begin to generate code for either JavaScript (simple typedef's) or PHP (classes extending sys.db.Object).

I am attempting to test the Context.defineType() function on a simple typedef for JavaScript context but having the following error when compiling:

allows to macro to compile, but as expected the following error comes up:

source/client/Main.hx:11: characters 8-15 : shared.TUser has no field ID

Attempting to add fields to the type definition in any way causes the error. Also, I am using --macro Parser.build("data/") at compile time to use initialisation macros. Would it be better to use the @:build() command?

The second parameter of FVar is indeed null, so I suspect the Context needs an expression there? What expression would it need to complete the kind because I’ve never needed to do this in the past (that being said, I’ve never used defineType before until now).

I found the problem! It had nothing to do with the code, it had to do with the fact that I had an empty line in the file and I interpreted it as a field… It was therefore creating an empty field with a null name that was then being added to the type definition. It’s working now.

I’ve corrected the interpretation to check if the name is valid and a type exists.