2 ms·
TypeScript imposes more detailed typing onto JS objects. It makes sense to ask the question: can the type imposed by TS onto a JS object be reified as a run-tim
by kazinator 3y ago
TypeScript imposes more detailed typing onto JS objects. It makes sense to ask the question: can the type imposed by TS onto a JS object be reified as a run-time object?
It could be, but maybe the use cases for that can be solved in another way that don't require the type system at run-time.
The good news is that static type is, well, static. All the objects of the same type can share a pointer to the same type metadata. The overhead is thus not necessarily huge: one extra property to initialize when an object is created.
The generated TS code has to carry the run-time support routines for the type stuff though.