ahrefs/atd

Backward compatibility

AndreyErmilov opened this issue · 1 comments

Hi all,
Thank you so much for your work on the library.

I am facing a problem. I was using version 2.2.1 and my code looked like this

name: string <json name="Name">;

After I upgraded to 2.3.3, I got compile errors. The documentation says to write it like this

name <json name="Name"> : string;

It looks like the minor version broke backward compatibility.
Is it just a bug that got into the release?

In 2.3.x, we added a validator to detect invalid annotations like those. Your old code was incorrect:

name: string <json name="Name">;

is the same as just

name: string;

which isn't what you wanted. This particular issue of having to place the annotation next to the field name isn't new and trips a lot of people. It was part of the motivation for adding some validation.

I recommend that you fix your atd file if that's an option. This will change (and fix) the behavior of your code. Otherwise, you could require the previous version of atdgen (< 2.3.0) so as to not break your build, and fix the annotations manually when you get a chance. Running atdgen -j foo.atd using atdgen >= 2.3.0 will tell you if there are any misplaced or misspelled annotations.