I know that typescript doesn't have advanced types, but can a book like this be adapted to use typescript ?
How does Idris solve this problem when compiling to JavaScript?
There is no problem compiling dependent (or static) types to JaveScript, as the type checks are done at compile time, and don’t require any support from the JavaScript runtime.