Skip to content

Export BatchResponseBody interface type #531

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

Merged
merged 2 commits into from
Nov 19, 2021
Merged

Conversation

henhal
Copy link
Contributor

@henhal henhal commented Nov 12, 2021

The BatchResponseBody interface is needed as parameter to several public methods, in particular the constructor for BatchResponseContent, but is not exported. This makes it harder to write type-safe code that makes a batch request and passes the body from the response JSON to BatchResponseContent without relying on implicit "any" typing.

A similar PR may already be submitted! Please search among the Pull request before creating one.

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request.

NOTE: PR's will be accepted only in case of appropriate information is provided below

Summary

Export an interface type which is used in other exported interfaces and methods.

Motivation

The BatchResponseBody interface is needed as parameter to several public methods, in particular the constructor for BatchResponseContent, but is not exported. This makes it harder to write type-safe code that makes a batch request and passes the body from the response JSON to BatchResponseContent without relying on implicit "any" typing.

Test plan

Trivial change affecting no code paths except exporting a previously internal type.

Closing issues

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

The BatchResponseBody interface is needed as parameter to several public methods, in particular the constructor for BatchResponseContent, but is not exported. This makes it harder to write type-safe code that makes a batch request and passes the body from the response JSON to BatchResponseContent without relying on implicit "any" typing.
@henhal
Copy link
Contributor Author

henhal commented Nov 12, 2021

My current workaround is to declare this locally:

type BatchResponseBody = ConstructorParameters<typeof BatchResponseContent>[0];

It would be much cleaner if the type is exported straight from the library.

@nikithauc nikithauc self-requested a review November 15, 2021 17:49
@nikithauc
Copy link
Contributor

@henhal Thank you for this PR!

Can you please add the export in src/index.ts and src/browser/index.ts?

@ghost
Copy link

ghost commented Nov 16, 2021

CLA assistant check
All CLA requirements met.

@henhal
Copy link
Contributor Author

henhal commented Nov 16, 2021

@nikithauc Of course, didn't realize members were exported explicitly from index.ts. How come export * from xxx isn't used? Anyway, I added the new type to the two index files. Thanks.

@nikithauc
Copy link
Contributor

@henhal Thank you so much for the update and making this contribution!

@nikithauc nikithauc merged commit 5183690 into microsoftgraph:dev Nov 19, 2021
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.

3 participants