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

fix(adapter-test): loosen env argument for easy process.env forwarding #201

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aleclarson
Copy link
Contributor

@aleclarson aleclarson commented Feb 4, 2025

While process.env (from @types/node) has Record<string, string | undefined> type, the env argument of @hattip/adapter-test expects a Record<string, string> type. I believe this is more strict than necessary. It'd be great to be able to pass process.env in without a type assertion.

Note: This builds upon #197 and so that PR should be merged first. Only this commit is relevant to this PR.

The `AdapterRequestContext#env` method uses this interface to provide type safety at compile-time. It allows the user to make certain assumptions about the existence of particular environment variables.
@@ -38,7 +38,7 @@ export function createTestClient<P = { name: "test" }>({
void promise;
},
env(variable) {
return env[variable];
return env[variable] as any;
Copy link
Contributor Author

@aleclarson aleclarson Feb 4, 2025

Choose a reason for hiding this comment

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

Due to #197's changes to the return type of env(), we have to cast to any.

Actually, this might belong in #197 (not sure).

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.

1 participant