12 ms·
It has nothing to do with any runtime. You just write const personType: Type = typeof(Person); This code gets compiled into const personType = {
by vbezhenar 3y ago
It has nothing to do with any runtime.
You just write
const personType: Type = typeof(Person);
This code gets compiled into
const personType = {
name: "Person",
fields: [
{ name: "lastName", type: "string" },
{ name: "firstName", type: "string" },
],
}
There's no runtime. It's just an object which describes layout of some time.
If you would implement validation by hand, you'd come up with absolutely conceptually identical code. Look at any validation libraries out there.
The only difference is: you specify types with nice TypeScript language, not with some made-up abomination DSL.
- can16358p 3y agoOh okay I was thinking of more of a runtime-code-emitting-dynamically kind of thing. If it's the way you've shown it'd be great!