-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
createEnv
from @t3-oss/env-nextjs
returns genric object when using Zod v3.23.0
#222
Comments
Same, just got a failed check with dependabot for Zod version bump. Following for resolution. |
Also experiencing this |
same, but i'm experiencing this with older zod versions as well. |
Someone know what types they've changed? We're not using any internal types so feels like they've unintentionally broken semver.
That's weird, please open a separate issue with a reproduction. |
@juliusmarminge Could it be related to this change? |
we're only using ZodType as a generic constraint so that shouldn't matter |
Was just about to do that from #223 |
Try this one: |
yup looks like canary fixes it for me |
Same for me. Though there is a breaking change on presets, which are now functions |
Yea this will be a 0.10 release. Needed to make them functions to avoid side-effects in the imports I'll go ahead and relese 0.10 now then |
Thanks for the quick action @juliusmarminge. I've fixed the underlying problem in Zod 3.23.2, so there's no need for everyone to upgrade. Perhaps add this as a note at the top of the original issue to avoid further confusion? Notes for those who are so inclined: Because declare function createEnv<
TServer extends Record<string, ZodType> = NonNullable<unknown>,
TClient extends Record<
`${ClientPrefix}${string}`,
ZodType
> = NonNullable<unknown>,
TShared extends Record<string, ZodType> = NonNullable<unknown>,
const TExtends extends Array<Record<string, unknown>> = [],
>(
opts: Options<TServer, TClient, TShared, TExtends>,
): Readonly<
(zod.objectUtil.addQuestionMarks<
zod.baseObjectOutputType<TServer>,
{
[k_1 in keyof zod.baseObjectOutputType<TServer>]: undefined extends zod.baseObjectOutputType<TServer>[k_1]
? never
: k_1;
}[keyof TServer]
> extends infer T_25
? {
[k in keyof T_25]: zod.objectUtil.addQuestionMarks<
zod.baseObjectOutputType<TServer>,
{
[k_1 in keyof zod.baseObjectOutputType<TServer>]: undefined extends zod.baseObjectOutputType<TServer>[k_1]
? never
: k_1;
}[keyof TServer]
>[k];
}
: never)
// ...
> This essentially means that that dependency on Zod is no longer "portable" and requires a specific version of Zod to work properly. Normally compiling something like this with @t3-oss/env-nuxt:build: src/index.ts(19,17): error TS2742: The inferred type of 'createEnv' cannot be named without a reference to '@t3-oss/env-core/node_modules/.pnpm/zod@3.23.0/node_modules/zod'. This is likely not portable. A type annotation is necessary. The utility type My fix was to add a second generic argument back to that type (a no-op): colinhacks/zod@ef588d0 I think an explicity return type on I'll also see if there's something I can do on my size to prevent Zod utilities from getting "inlined" like this in the future. Unrelated, there's also some kind of recursive unrollling happening due to |
|
I also get this issue. Reverting to |
Still a problem for me. Using: |
@juliusmarminge I can confirm this issue still persists like described above. Rolling back to 0.9.1 works for now |
If anyone still gets this please also provide a reproduction. Im using the latest version without issues |
When I install
Using version See https://codesandbox.io/p/devbox/dreamy-black-7l4ywn?workspaceId=78150bbe-056c-4c8d-8542-1698ecfb6c1d |
You're using an incompatible module resolution. See https://github.com/t3-oss/t3-env#installation for compatible options |
Ahhh I see. After I changed it to "moduleResolution": "Bundler",
"module": "esnext", it seems to work. Also I had to use proper |
After upgrading Zod to
v3.23.0
fromv3.22.5
,createEnv
from@t3-oss/env-nextjs
will always returnregardless of how the env vars are specified. The
createEnv
exported from@t3-oss/env-core
doesn't seem to be affected by this issue.Reproduction:
Hover the
env
variable to see the generated type.The text was updated successfully, but these errors were encountered: