Skip to content

fixed typing for Request constructor #362

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FlorianB-DE
Copy link
Contributor

Summary

This fixes the typing issue with the Request constructor.
Typescript typing is used to prevent runtime errors with compile time checks.

In these lines

if (!headers) {
throw new InvalidArgumentError('Missing parameter: `headers`');
}
if (!method) {
throw new InvalidArgumentError('Missing parameter: `method`');
}
if (!query) {
throw new InvalidArgumentError('Missing parameter: `query`');
}
, there are runtime errors thrown that are not reflected by the typescript typing and therefore not catchable by the Typescript compiler.

Linked issue(s)

#356 (comment)

Involved parts of the project

Typing declarations

Added tests?

No

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

constructor(options?: Record<string, any> | http.IncomingMessage);
constructor(options: {
headers: Record<string, string>,
method: string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might as well be an enum, but I wouldn't insist it.

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