The Typescript compiler could probably emit additional JS files with reflection info just as it currently emits .map and .d.ts files (basically a 'type database' that exposes the information that's already in the .d.ts file as JS module, and which can be queried at runtime by type- and property-names (e.g. stuff like "what was the original Typescript type for this Javascript property").
The only missing link is then that Javascript objects don't know their original Typescript type, that would need to be magically injected by the TS compiler as a custom property.
How useful that would be in practice, no idea... I can pretty much only see downsides (mainly increasing bloat).
Also the same thing can probably be implemented in 'user space' by a tool which parses .d.ts files and code-generates such type-database modules from that information.
The only missing link is then that Javascript objects don't know their original Typescript type, that would need to be magically injected by the TS compiler as a custom property.
How useful that would be in practice, no idea... I can pretty much only see downsides (mainly increasing bloat).
Also the same thing can probably be implemented in 'user space' by a tool which parses .d.ts files and code-generates such type-database modules from that information.