Hacker News new | ask | show | jobs
by podperson 149 days ago
OP again:

The tjs compiler transpiles ts into itself: https://platform.tosijs.net/#example=Hello+TypeScript&sectio...

It's written in typescript and can transpile itself.

When it transpiles typescript, type declarations become contracts, and types are available at runtime.

It does all this with a 50-70% overhead (imperceptible in most cases), but there's an unsafe escape hatch (!) => {} functions bypass type checks.

Oh yeah, it does inline WASM and it handles the hard stuff other WASM implementations kind of leave as an exercise -- moving data across. And it support SIMD.

https://platform.tosijs.net/#view=tjs&example=Vector+Search+...

Error propagation is monadic, so functions passed bad arguments just don't execute. Also functions know from whence they came and you can execute code in debug mode and get a trace with your monadic error, so it's very agent friendly.

If you code in tjs natively you can do inline tests of unexported functions at transpile time.

If you transpile ts using tjs it gives you the same capability.

Single pass transpilation does inline tests and generates documentation at the same time.

tjs itself is a TRUE js superset with predicate functions to handle complex types (if your type system is going to be turing complete, own it), full introspection (so it's a true LISP, or what Dylan aspired to be), and safe Eval using a language subset that is deeply async. Again, universal endpoints.

Simple types are declared by example, so:

function greet(name: 'Alice') -> 'Hello, Alice' => `Hello, ${name}`

is not just a declaration of a function that takes a string and returns a string, but the string should look like 'Alice' and if it is 'Alice' the function will return 'Hello, Alice' and this is also an inline test that runs at transpile time.