-
Notifications
You must be signed in to change notification settings - Fork 394
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
Make typescript and zod optional peer dependencies #174
Conversation
It does mean we'll have to be careful not to re-export either from the top-level entry point, as that would introduce errors, right? |
Yes, correct. |
Though, given most people run skipLibCheck, they may not. But, they will still have needed to either install zod anyway to even construct the schema, and the chances that they won't have typescript installed for the other case seem super slim. |
We like this in theory, but we do need all the examples to have explicit dependencies on Additionally, we need to decide on which examples use Zod vs TypeScript. |
Is the intent that the examples can be fully extracted out? As it stands now, they get typescript from the repo root. |
Yeah, it's that and also general guidance on how one would would do the same. |
Currently they devDep; I'll upgrade the ones using TS when I get a chance. |
#147 added zod support, and then moved both zod and typescript support into separate modules / declared exports. The only way to access these are via importing
typechat/ts
andtypechat/zod
.This PR makes those packages optional peer dependencies. This means that those depending on typechat don't need to install the dependencies for any of the entrypoints they aren't using.
For example, if you're using the zod provider, you will necessarily have installed zod in your package as well in order to construct a schema. But, if you haven't and are instead using typescript, then zod won't be installed.
If someone forgets a dep, they'll get a compiler error complaining about a missing import, so that case should be pretty clear.