|
|
|
|
|
by mmastrac
655 days ago
|
|
The problem with TypeScript is that it’s purely “advisory.” The actual shape of the objects at runtime might not match the declared types in the system, and once type-checking is complete, it’s a free-for-all. That being said, you can use AssemblyScript, which offers a “type hints that optimize” approach. Unlike TypeScript, AssemblyScript is compiled to WebAssembly and leverages type information. Under the hood, V8 performs its own shape analysis on objects to optimize performance. It’s quite effective and can handle a lot of optimization scenarios, though it would be interesting if V8 could use TypeScript’s type information to pre-seed the optimizer with known object shapes (it does not currently). |
|