Skip to content

Commit

Permalink
fix: handle empty env object type (#21)
Browse files Browse the repository at this point in the history
* fix: handle empty env object type

* bug: add failing test for #17

* Update packages/nextjs/index.ts

* fix: exclude `dist` in tsconfig

* chore: add changeset

* Update .changeset/dirty-impalas-juggle.md

---------

Co-authored-by: Julius Marminge <julius0216@outlook.com>
  • Loading branch information
chungweileong94 and juliusmarminge committed Apr 28, 2023
1 parent 7e192c7 commit fcf6851
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/dirty-impalas-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@t3-oss/env-core": patch
"@t3-oss/env-nextjs": patch
---

Fix empty env object type
4 changes: 2 additions & 2 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export interface StrictOptions<

export function createEnv<
TPrefix extends string,
TServer extends Record<string, ZodType>,
TClient extends Record<string, ZodType>
TServer extends Record<string, ZodType> = NonNullable<unknown>,
TClient extends Record<string, ZodType> = NonNullable<unknown>
>(
opts:
| LooseOptions<TPrefix, TServer, TClient>
Expand Down
3 changes: 2 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "../../tsconfig.json",
"include": ["index.ts", "tsup.config.ts", "test"]
"include": ["index.ts", "tsup.config.ts", "test"],
"exclude": ["dist"]
}
7 changes: 5 additions & 2 deletions packages/nextjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ interface Options<
}

export function createEnv<
TServer extends Record<string, ZodType>,
TClient extends Record<`${ClientPrefix}${string}`, ZodType>
TServer extends Record<string, ZodType> = NonNullable<unknown>,
TClient extends Record<
`${ClientPrefix}${string}`,
ZodType
> = NonNullable<unknown>
>({ runtimeEnv, ...opts }: Options<TServer, TClient>) {
return createEnvCore<ClientPrefix, TServer, TClient>({
...opts,
Expand Down
3 changes: 2 additions & 1 deletion packages/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "../../tsconfig.json",
"include": ["index.ts", "tsup.config.ts", "test"]
"include": ["index.ts", "tsup.config.ts", "test"],
"exclude": ["dist"]
}

1 comment on commit fcf6851

@vercel
Copy link

@vercel vercel bot commented on fcf6851 Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

t3-env – ./

t3-env-git-main-t3-oss.vercel.app
env.t3.gg
t3-env-t3-oss.vercel.app
t3-env.vercel.app

Please sign in to comment.