You can find bellow a working version in ReScript of your code, don’t forget to enable auto-run if you want to test it live.
You can notice how close to the typescript version it is, it’s almost identical, you basically need to remove the type annotations and the return keyword.