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

Type-safe: source adapters #1311

Open
bryanjowers opened this issue Dec 15, 2021 · 0 comments
Open

Type-safe: source adapters #1311

bryanjowers opened this issue Dec 15, 2021 · 0 comments

Comments

@bryanjowers
Copy link
Collaborator

bryanjowers commented Dec 15, 2021

To give our source adapters higher type safety we should ensure that every Axios request gives a typed response.

An example of adding this can be seen in this PR:
#1239

For each endpoint:

  1. Add a ResponseSchema interface containing the structure of the API response. If integration tests are finished for the EA it should be easy to pull from there.
  2. Consume it in the HTTP call by passing this interface as a generic
  const response = await Requester.request<ResponseSchema>(options, customError)
  1. Set the result to its own variable instead of modifying the response data.
  const result = Requester.validateResultNumber(response.data, [speed]) * 1e9
  1. Use the Requester.withResult utility to merge the result into the response data while maintaining types:
  return Requester.success(jobRunID, Requester.withResult(response, result), config.verbose)

The end goal is to be able to turn on the "noAny" and "noImplicitAny" settings in TypeScript across the whole mono-repo.

Acceptance criteria:

  • demonstrate that there are no warnings if "noAny" and "noImplicitAny" are enabled

Granular tracking on the tracking sheet (shared privately)

@bryanjowers bryanjowers changed the title Type safe: source adapters Type-safe: source adapters Dec 15, 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

No branches or pull requests

1 participant