It's a DSL like regex, for these constraints it makes sense to me. To me it's more TS than what you imply, which is JS.
I believe that if the candidate is able to whip this up in 30-60 minutes they know their shit around some math and TS.
I think most problems are not this low-level and I think the questions about data management (DB, data structures in memory and on disk), API design, integration with services and other higher-level skills are more important.
So compared to the baseline "JS" at least this candidate effectively showed off one extra interesting and hard skill, while solving the problem flawlessly, and not folding under pressure, and so on.
In the text the candidate explicitly asked for permission to go with types. And if the interviewer wanted to revoke that permission they could have, but they did not, they gave some ambiguous advice.
> If you really wanted the job, would you behave like that in the interview?
Yes. I don't want to work for a company where creativity is a liability.