Comment

Comment by MrResearcher

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.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton