3 ms·
The lack of RTTI in TypeScript _is_ definitely a pain but the jump to "must use decorators" and "TypeScript is not a server language" is unjustified. There are
by danvk 3y ago
The lack of RTTI in TypeScript _is_ definitely a pain but the jump to "must use decorators" and "TypeScript is not a server language" is unjustified. There are many approaches to validation and RTTI with TS. For example, you can generate JSONSchema from your TS types (see https://github.com/danvk/crosswalk https://github.com/danvk/crosswalk for an example of this approach) or you can use a tool like Zod (https://zod.dev/ https://zod.dev/) to declare your schemas as runtime values and derive TS types from those.
Writing your backend in Java or C# comes with its own issues, i.e. you can't share code between backend and frontend.
- shortrounddev2 3y agoThe solutions you described are hacks, at best, trying to compensate for the deficiencies of the language. I have never wanted to share code between frontend and backend other than classes/type information. I don't know why you would want to repeat code