-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
There’s many times when I want to generate code based on TS types, like data validators, OpenAPI schemas, and test data generators. TS explicitly does not support generating or changing the runtime semantics of code (except for enums) so there’s no way to do this. The alternative that people have come up with is to use tools like zod to infer types from a runtime combinator library, but this is limiting. The code is challenging to write and there’s no way to control the representation of inferred types in intellisense, so the development ergonomics are not as good as they would be if we could go from types -> code via macros.
TS doesn’t have monadic do notation, which is something that I want very badly. This would be easy to add to JavaScript with Sweet.js macros, but there’s no equivalent tool for TypeScript. I expect that extending this to TypeScript would be very difficult.
I, like many functional programmers, desperately wish that TypeScript had higher-kinded types. There’s a way to simulate them using some boilerplate and unsafe casts, but I have found that this makes code much harder to read when doing advanced operations. With macros, we could generate the coercion functions automatically and transform the type signatures to look better. We’d still have to call the coercion methods manually, and we’d get worse type inference, but it could be worth a try.
Related posts
-
Simplifying Form Validation with Zod and React Hook Form
-
From Flaky to Flawless: Angular API Response Management with Zod
-
You can’t run away from runtime errors using TypeScript
-
Epic Next JS 14 Tutorial Part 4: How To Handle Login And Authentication in Next.js
-
Error handling in our form component for the NextAuth CredentialsProvider