3 ms·
I still don't see the point. There is a long list of libraries that do exactly this, and do it well enough. The author has linked to them himself. The overall b
by paxys 3y ago
I still don't see the point. There is a long list of libraries that do exactly this, and do it well enough. The author has linked to them himself. The overall benefit of this would be maybe slightly better syntax for these libraries (even that is doubtful, because plenty of them already have a `reflect<T>()` interface), but still zero runtime benefit. And getting it to be accurate for 100% of cases would entail exactly what I mentioned – writing an entire runtime to do this inference.
- Nullabillity 3y agoSo now you're stuck writing for an awkward inner platform language rather than using the TS syntax itself.
- paxys 3y agoWhat's this "awkward inner platform language"? They are asking for a `typescript.generateRuntimeType<T>()` function to be native to the language. Well plenty of libraries provide exactly this syntax today. Here's tst-reflect: `const type = getType<T>()`. Notice any difference?
- Nullabillity 3y agoBut tst-reflect seems to work by effectively building their own forked tsc compiler.
- paxys 3y agoNo, they have a plugin into the typescript compiler which uses their API. tsc already exposes all of the info they need.
- Dylan16807 3y agoOkay so it's not a forked compiler but it's adding a feature to the compiler. At which point it makes a lot of sense to ask why that feature shouldn't be merged.
- auggierose 3y agoBecause of feature creep. I don't need that feature. Don't merge things that can be kept separate. It is called modularity.
- Nullabillity 3y agoAccording to their (tst-reflect's) README, tsc doesn't support plugins. The plugin support comes from a fork called ttsc.
- andix 3y agoWow, i didn't know that this is already possible with type script. seems like there are transformers you can add to typescript that can implement it. So type script more or less supports the feature they asked for. Just not bundled with the main package, but they provide the interface to get it done with 3rd party transformers.