-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support for Deno #209
Add support for Deno #209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you able to run the tests in a Deno environment? I'd like some way to verify that this continues to work for Deno, especially if a single extension-less import will break everything.
@@ -9,7 +9,7 @@ type CatcherItem = { type: 'catcher'; catcher: Catcher }; | |||
type Items = (FuncItem | CatcherItem)[]; | |||
|
|||
export class PseudoPromise<ReturnType = undefined> { | |||
readonly _return: ReturnType; | |||
readonly _return: ReturnType | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the following error when undefined is not added
error: TS2564 [ERROR]: Property '_return' has no initializer and is not definitely assigned in the constructor.
readonly _return: ReturnType;
@@ -1,4 +1,4 @@ | |||
import * as z from '..'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't have to be ../index.ts
?
It seems to be hard to use deno in combination with jest. I have converted all the tests to deno test. They all run green in github actions |
Not sure what to do here. I can't merge this into master since now all the tests are written with |
I think we should do this in smaller steps.
|
8863e9f
to
e10041b
Compare
I have changed the approach a bit.
Open question is how to publish the deno version. Common in deno land is to push your scr files to github. Only it would be a bit wierd to have the sources duplicated in the project. |
d915a1b
to
4d23a94
Compare
@wilmveel Thanks for this branch, I'm using it locally to get started with Zod. However, FYI it appears to have broken with this change in Deno 1.5:
|
Hej Jeremy,
I aware of this issue. In deno 1.5 isolated modules is enabled bij default.
Zod is not compatible with this new feature. Would be nice to change Zod to
support this.
…On Fri, Nov 27, 2020, 23:58 Jeremy Banks ***@***.***> wrote:
@wilmveel <https://github.com/wilmveel> Thanks for this branch, I'm using
it locally to get started with Zod. However, FYI it appears to have broken
with this change in Deno 1.5
<https://deno.land/posts/v1.5#stricter-type-checks-in-stable>:
This release enables the isolatedModules TypeScript compiler option for
all users by default. In the 1.4 release this flag was enabled for users
using --unstable.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#209 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5JY3PYISZSZLV6YNJVZQDSSAVKFANCNFSM4THEL6LA>
.
|
@wilmveel what would that entail? |
If I understand correctly (I may not, take this with a grain of salt), the recommended way to deal with this is to use TypeScript 3.8's It looks like there's also an option to change this behaviour in tsconfig, which might be acceptable for my personal projects, but Deno's default tsconfig is used almost everywhere and libraries are generally expected to work under that config. |
Tried out a few changes 8eb5a47...f381bbe, confirming that this branch works on the current version of Deno if we override the tsconfig, or if we change a few imports over to It looks like a that drop-in-replacement for Jest has also become broken, but I've submitted a fix: allain/expect#13 |
I found another way to publish the Deno package via unpkg. Instead of pushing the sources twice to GitHub. I have implemented this example in flock-community/zod-endpoints. unpkg.com/zod-endpoints/lib/deno/mod.ts I can change this pr if you like this approach more. Downside you cannot be registered as third party package at deno.land |
It would be a shame if we couldn't publish Zod to I will see if we can work around the I don't think it's possible to avoid committing the generated Deno duplicate of the code (although if it's seen as too much clutter, they only really need to be there for the tagged commits, and can be deleted in between). We could add an Action to automatically generate and commit the Deno version of the code whenever changes are pushed (or maybe only when sent for pull requests?) to reduce the overhead. |
@colinhacks You may want to consider registering the
(We may need to change that URL to |
Done! Thanks for the guidance @jeremyBanks. Btw, Zod v2 is coming out of beta shortly and I've bumped the minimum TypeScript version to 3.7. That may help with these efforts. |
I've been trying some workarounds for making isolated modules work in 3.7 (without Other workarounds lose necessary type information. I'll look at it a bit more, but I'm not optimistic. It may not be what Zod needs at this time, but if any other Deno users want something they can use Right Now, I have a branch at #247 that works in Deno and TypeScript 3.8. |
@jeremyBanks I see you have created an alternative for denoify. Is it possible to release this script separately? I would like to use it for another project I'm working on. |
@wilmveel I don't really mean to make that deno-library-building script suitable for general use. More general-purpose tools like Denoify already exist, and I don't think I'd be contributing anything new. But I thought it would be easier for Zod development to have a small single-purpose script committed here instead. Feel free to copy my script (I hereby release it to the public domain/cc0), but I'm not sure it would be worth me releasing it as its own thing. |
It looks like This is clearly a bug on Deno's side. I'll see if it's already being tracked, or if we can get a fix in the next Deno release. EDIT: It looks like it's a bug in SWC, which Deno depends on. I've filed an issue. I'm not sure it's within the scope of my abilities to fix. |
@wilmveel @jeremyBanks these efforts looks excellent, tag me if/when this is ready for primetime and I'll deploy to deno.land/x. Are you guys waiting on anything from me, or are we just waiting for upstream bugs to resolve? |
@colinhacks I would suggest we may want to wait for upstream to fix the We do not currently have a solution implemented for the |
As it turns out I'll potentially be shipping the beta for Zod 3 soon to fix some architectural issues that have been plaguing transformers: #264. I'm more than happy to bump the minimum version for Zod 3 to TS 4.0, maybe even 4.1, since it'll be in beta for a long time. But regardless of that I'm happy having different minimum TS version requirements for the Deno and non-Deno versions. (This only applies if we're able to figure out how to generate the |
Since Zod 3 can have certain breaking changes, could we just get rid of the offending syntax? If its as simple as renaming Also is there any other reasons your PR is still a draft? If not I'll merge it into my v3 branch. |
@colinhacks Thanks for the feedback.
Cool. In that case, I would suggest bumping it the minimum TypeScript version to 3.8 for Zod 3. If we used a codemod or regex to make the
I think that might be all we need to change. I'll give it a try, and if it works, send an updated PR for Deno support targeting the v3 branch. (edit: it didn't work but I still updated #269 to add Deno compatibility.) |
Closing in favor of #269 |
For a side project zod-router we are using zod in combination with deno. To be able to use zod with deno it is necessary to use the full path of the files including the extension for all imports. Would it be possible to publish zod in a way that it is node and deno compatible.