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

Create runtypes from existing TypeScript types? #306

Open
aaronransley opened this issue Jun 25, 2022 · 1 comment
Open

Create runtypes from existing TypeScript types? #306

aaronransley opened this issue Jun 25, 2022 · 1 comment

Comments

@aaronransley
Copy link

aaronransley commented Jun 25, 2022

Hi there, I'm curious if it's possible to create runtype types from existing TypeScript types?

Specifically, I am hoping to avoid:

  • Having to comb the codebase and redefine types as runtypes manually
  • Having to cast these new runtypes into TypeScript types using Static<T>

Perhaps this simply isn't possible due to the TypeScript architecture, but I'd be curious to know more if you have a moment to share. From what I can gather, there isn't a single "runtime types library" out there that doesn't rely either on:

  • Defining types using a library provided API instead of vanilla TypeScript
  • Exporting types to JSON Schema or some interchange format as a discrete build step

Lastly, I just wanted to thank you for your work on this library. It has a wonderfully intuitive API and it's easy to see the amount of care that went into documentation & general developer ergonomics ✨

@nir581
Copy link

nir581 commented Oct 31, 2023

I'll add and say that one the disadvantages that I see currently in the fact that we can't create a runtype from a given TS type or interface, is the fact that you can't use the "find usages" action in your IDE to review all the places that you are using a specific property of that runtype, while that can easily be done if you apply it on a well defined TS type/interface.
Another thing I came across today is a usecase where you want to rename an existing property of a runtype in a project. Because the IDE doesn't have the above connection between a runtype and its properties, you can't rename a property in a single automatic action, you have to do it manually which is annoying and error prune.
WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants