3 ms·
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: "fie
by MrResearcher 3y ago
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.
- gloryjulio 3y agoU just need a library to enable this to reduce the boilerplate. I don't see how that's impossible
- asherah 3y agothis wouldn't work for interfaces, or more complicated types
- epolanski 3y agoThis is as useful as vue 2's prop types: very little.