It came up a lot when making HTML-based forms. I’d define them all in PHP, but the experience is best without a page load, so typically I define some typescript object to send the form via Ajax. I got tired of having to define all the field names in both places (awful for maintenance), so instead typescript uses AJAX to ask the server for the list of inputs it needs to grab and send.
It sounds like Haxe could be a much nicer way to do stuff like that: https://haxe.org/use-cases/web/