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

Make typescript and zod optional peer dependencies #174

Merged
merged 4 commits into from
Mar 19, 2024

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jan 23, 2024

#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 and typechat/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.

@DanielRosenwasser
Copy link
Member

If someone forgets a dep, they'll get a compiler error complaining about a missing import, so that case should be pretty clear.

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?

@jakebailey
Copy link
Member Author

Yes, correct.

@jakebailey
Copy link
Member Author

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.

@DanielRosenwasser
Copy link
Member

We like this in theory, but we do need all the examples to have explicit dependencies on typescript rather than listing it in devDependencies.

Additionally, we need to decide on which examples use Zod vs TypeScript.

@jakebailey
Copy link
Member Author

Is the intent that the examples can be fully extracted out? As it stands now, they get typescript from the repo root.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 18, 2024

Is the intent that the examples can be fully extracted out?

Yeah, it's that and also general guidance on how one would would do the same.

@jakebailey
Copy link
Member Author

Currently they devDep; I'll upgrade the ones using TS when I get a chance.

@DanielRosenwasser DanielRosenwasser merged commit f193e63 into microsoft:main Mar 19, 2024
5 checks passed
@jakebailey jakebailey deleted the optional-peer branch March 19, 2024 15:40
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

Successfully merging this pull request may close these issues.

2 participants