Skip to content

Narrow willSendRequest's parameter type #161

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

Closed
wants to merge 3 commits into from

Conversation

haines
Copy link
Contributor

@haines haines commented Sep 16, 2020

It's a bit of a pain when implementing willSendRequest in TypeScript with strict null checks, because request.http is typed as optional, even though its presence is guaranteed. We therefore have to do something like

request.http!.headers.set(...)

In this PR I've casted the request passed to this function to a narrower type with http required, so that we can avoid the non-null assertion when implementing the method.


Originally at: apollographql/apollo-server#3587

@haines haines closed this Mar 24, 2022
@dariuszkuc dariuszkuc deleted the apollo-server-import/pr-3587 branch March 29, 2023 20:58
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.

2 participants