Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 25, 2022
1 parent 670eb04 commit 8ced192
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 33 deletions.
2 changes: 1 addition & 1 deletion source/as-promise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default function asPromise<T>(normalizedOptions: NormalizedOptions): Canc
}

globalResponse = response;

if (!isResponseOk(response)) {
request._beforeError(new HTTPError(response));
return;
Expand Down
2 changes: 1 addition & 1 deletion source/core/calculate-retry-delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const calculateRetryDelay: Returns<RetryFunction, number> = ({attemptCount, retr
}

const hasMethod = retryOptions.methods.includes(error.options.method);
const hasErrorCode = retryOptions.errorCodes.includes(error.code!);
const hasErrorCode = retryOptions.errorCodes.includes(error.code);
const hasStatusCode = error.response && retryOptions.statusCodes.includes(error.response.statusCode);
if (!hasMethod || (!hasErrorCode && !hasStatusCode)) {
return 0;
Expand Down
20 changes: 10 additions & 10 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ export type OptionsWithPagination<T = unknown, R = unknown> = Merge<Options, Pag
An instance of `got.paginate`.
*/
export interface GotPaginate {
/**
Same as `GotPaginate.each`.
*/
<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;

/**
Same as `GotPaginate.each`.
*/
<T, R = unknown>(options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;

/**
Returns an async iterator.
Expand Down Expand Up @@ -150,16 +160,6 @@ export interface GotPaginate {
*/
all: (<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>) => Promise<T[]>)
& (<T, R = unknown>(options?: OptionsWithPagination<T, R>) => Promise<T[]>);

/**
Same as `GotPaginate.each`.
*/
<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;

/**
Same as `GotPaginate.each`.
*/
<T, R = unknown>(options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;
}

export interface GotRequestFunction {
Expand Down
10 changes: 0 additions & 10 deletions test/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ test('can omit `url` option if using `prefixUrl`', withServer, async (t, server,
await t.notThrowsAsync(got({}));
});

test('throws TypeError when `options.hooks` is not an object', async t => {
await t.throwsAsync(
// @ts-expect-error Error tests
got('https://example.com', {hooks: 'not object'}),
{
message: 'Expected value which is `predicate returns truthy for any value`, received value of type `Array`.'
}
);
});

test('throws TypeError when known `options.hooks` value is not an array', async t => {
await t.throwsAsync(
// @ts-expect-error Error tests
Expand Down
9 changes: 0 additions & 9 deletions test/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ test('`http.request` error through CacheableRequest', async t => {
});
});

test('errors are thrown directly when options.isStream is true', t => {
t.throws(() => {
// @ts-expect-error Error tests
void got('https://example.com', {isStream: true, hooks: false});
}, {
message: 'Expected value which is `predicate returns truthy for any value`, received value of type `Array`.'
});
});

test('normalization errors using convenience methods', async t => {
const url = 'undefined/https://example.com';
await t.throwsAsync(got(url).json().text().buffer(), {message: `Invalid URL: ${url}`});
Expand Down
3 changes: 2 additions & 1 deletion test/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const testIPv6 = (IPv6supported && process.env.TRAVIS_DIST !== 'bionic' && proce
const echoIp: Handler = (request, response) => {
const address = request.connection.remoteAddress;
if (address === undefined) {
return response.end();
response.end();
return;
}

// IPv4 address mapped to IPv6
Expand Down
6 changes: 5 additions & 1 deletion test/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ test('custom error codes', async t => {
request: () => {
const emitter = new EventEmitter() as http.ClientRequest;
emitter.abort = () => {};

// @ts-expect-error
emitter.end = () => {};

// @ts-expect-error
emitter.destroy = () => {};

const error = new Error('Snap!');
Expand All @@ -184,7 +188,7 @@ test('custom error codes', async t => {
},
retry: {
calculateDelay: ({error}) => {
t.is(error.code as string as typeof errorCode, errorCode);
t.is(error.code, errorCode);
return 0;
},
methods: [
Expand Down

0 comments on commit 8ced192

Please sign in to comment.