-
-
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
Empty extends
array introduces type error TS2339
#179
Comments
don't see a real issue here since you can just remove the empty array if you're not extending anything. obviously open for a fix if anyone wants to spend time on it but i probably wont fix it myself tbh... |
looks like extends is just broken, not only for empty arrays but: import { createEnv } from "@t3-oss/env-nextjs";
import { vercel } from "@t3-oss/env-nextjs/presets";
import { z } from "zod";
// env is never
export const env = createEnv({
extends: [vercel()],
shared: {
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
},
/**
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z
.string()
.url()
.refine(
(str) => !str.includes("YOUR_MYSQL_URL_HERE"),
"You forgot to change the default URL",
),
UPSTASH_REDIS_REST_TOKEN: z.string(),
UPSTASH_REDIS_REST_URL: z.string(),
TELEGRAM_TOKEN: z.string(),
},
/**
* Specify your client-side environment variables schema here.
* For them to be exposed to the client, prefix them with `NEXT_PUBLIC_`.
*/
client: {
// NEXT_PUBLIC_CLIENTVAR: z.string(),
NEXT_PUBLIC_TEST_IP: z.string().optional(),
},
/**
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
*/
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_TEST_IP: process.env.NEXT_PUBLIC_TEST_IP,
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
TELEGRAM_TOKEN: process.env.TELEGRAM_TOKEN,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
skipValidation:
!!process.env.CI || process.env.npm_lifecycle_event === "lint",
}); |
Background
Hi there! I'm having the following compile error TS2339 when I keep the
extends
key as an empty array.The workaround I've found is simply removing the
extends
key, which of course makes sense if I'm not using it. But I wasn't expecting it to introduce compile errors for the environment variables for keeping theextends
key around, for perhaps future use of it.My environment config
Relevant Package Versions
v0.8.0
v13.4.19
v5.2.2
Project
tsconfig
settings:The text was updated successfully, but these errors were encountered: