Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] Generate runtime types with io-ts #100

Closed
silasdavis opened this issue Jun 5, 2020 · 1 comment
Closed

[Idea] Generate runtime types with io-ts #100

silasdavis opened this issue Jun 5, 2020 · 1 comment

Comments

@silasdavis
Copy link
Contributor

silasdavis commented Jun 5, 2020

I have been enjoying 'database-first domain modelling', and also io-ts (having come across it here) (thanks).

Thinking about higher-order types, custom types, and type overrides #60 at the same time as defining io-ts schema has made me wonder if io-ts should generate runtime types (rather than static types) using io-ts. It would be strictly more powerful and not much more effort from the code generation side (actually it might be easier https://github.com/gcanti/io-ts-codegen).

You can still get hold of types by using t.TypeOf<typeof IoTsSchema> so we can just put that everywhere we'd currently put our existing types.

This allows dependees not only to check their code for type agreement but also to parse inputs that are related to database-defined schema (as they surely must be). This could allow the DB schema to be the statically typed centre of a system. Inputs can be typed at run-time and compile-time from schema derived from the DB.

I think io-ts will be much better than the inchoate type system I added for enums for transporting type information around for composite types. And I can't entirely put my finger on why yet, but I think using runtime types at generation time and in generated code (as well as to carry the database type mapping) is going to unlock some powerful features.

@silasdavis silasdavis changed the title Generate runtime types with io-ts [Idea] Generate runtime types with io-ts Jun 7, 2020
@adelsz
Copy link
Owner

adelsz commented Feb 9, 2023

Closing as stale. Runtime type validation is a non-goal.

@adelsz adelsz closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants