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

Sweep: Fix typing error when running tests with Jest #262

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export type RateObj = {

/**
* The response from the exchange rates API.
* Can be a single exchange rate or an array of exchange rates.
* An array of exchange rates.
*/
export type RateResponse = RateObj | [RateObj];
export type RateResponse = RateObj[];

const defaultOptions: RequestOptions = {
host: 'bitpay.com',
Expand All @@ -41,7 +41,7 @@ const returnPromise = (options: RequestOptions): Promise<RateResponse> => {

res.on('end', () => {
try {
const { data } = JSON.parse(dataBuffer);
const { data } = JSON.parse(dataBuffer) as { data: RateObj[] };
return resolve(data);
} catch (err) {
return reject(err as Error);
Expand All @@ -54,7 +54,7 @@ const returnPromise = (options: RequestOptions): Promise<RateResponse> => {
});
};

export const get = (code?: string): Promise<RateResponse> => {
export const get = (code?: string): Promise<RateObj[]> => {
if (typeof code === 'string') {
defaultOptions.path += `/${code.toUpperCase()}`;
}
Expand Down