Hacker News new | past | comments | ask | show | jobs | submit login

Typescript already kind of has it, it's just they got it backwards.

One needs to define their types as a const, like this one:

``` [{ type: Number, name: "field1" }, { type: String, name: "field2" }] as const ```

and then use Typescript magic to convert it into the fully fledged Typescript type.

Yes, it's annoying, but it's more flexible.




U just need a library to enable this to reduce the boilerplate. I don't see how that's impossible


This is as useful as vue 2's prop types: very little.


this wouldn't work for interfaces, or more complicated types




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: