Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Oh 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!




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

Search: