News for hackers. Stuff that matters.
Re:TypeScript’s quirks: How inconsistencies make the languag... by nkingsy on Friday January 31, 2020 @11:24PM (#22208644)
I’d suggest generating code

Write your interface in json or text proto then build it to ts interfaces and runtime checks.

Re:TypeScript’s quirks: How inconsistencies make the languag... by aabbcc1241 on Saturday February 01, 2020 @12:29AM (#22208885)
Agree with the code generation approach. Otherwise you need to make sure the annotations are in sync with the type / class / interface.

Typescript doesn't support macro currently, so code generation is the only way to programmatically create 'type-checked' code.

Some cli-tool and library I'm using (available on npm):

tsc-macro: https://github.com/beenotung/tsc-macro

gen-ts-type: https://github.com/beenotung/gen-ts-type

ts-type-check: https://github.com/beenotung/ts-type-check