|
|
|
|
|
by noduerme
1424 days ago
|
|
Interesting. > Instead, encourage programming patterns that do not require run-time metadata. I can understand why. But there are times when any alternative pattern is a worse choice. Then it's left to the coder to hack together type checks however it's convenient. Does the Dog class really need a static variable typed to Dog|Cat... ? It would be nice if instead of a dozen nonstandard ways to do that, some metadata could be emitted if you wanted to. TS does weird stuff like emitting functions to define enums, for instance. |
|
It doesn't- because classes are a native JS concept and not a TS concept; they already have the metadata to distinguish them
> TS does weird stuff like emitting functions to define enums, for instance
Not sure what's meant by this; TypeScript does introduce enum syntax which technically generates runtime code (one of the few instances), though it's just very light sugar over constants, and using it is also sorta advised against these days