Skip to content

Commit 8ced192

Browse files
committed
Fix build
1 parent 670eb04 commit 8ced192

File tree

7 files changed

+19
-33
lines changed

7 files changed

+19
-33
lines changed

source/as-promise/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default function asPromise<T>(normalizedOptions: NormalizedOptions): Canc
125125
}
126126

127127
globalResponse = response;
128-
128+
129129
if (!isResponseOk(response)) {
130130
request._beforeError(new HTTPError(response));
131131
return;

source/core/calculate-retry-delay.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const calculateRetryDelay: Returns<RetryFunction, number> = ({attemptCount, retr
1010
}
1111

1212
const hasMethod = retryOptions.methods.includes(error.options.method);
13-
const hasErrorCode = retryOptions.errorCodes.includes(error.code!);
13+
const hasErrorCode = retryOptions.errorCodes.includes(error.code);
1414
const hasStatusCode = error.response && retryOptions.statusCodes.includes(error.response.statusCode);
1515
if (!hasMethod || (!hasErrorCode && !hasStatusCode)) {
1616
return 0;

source/types.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ export type OptionsWithPagination<T = unknown, R = unknown> = Merge<Options, Pag
104104
An instance of `got.paginate`.
105105
*/
106106
export interface GotPaginate {
107+
/**
108+
Same as `GotPaginate.each`.
109+
*/
110+
<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;
111+
112+
/**
113+
Same as `GotPaginate.each`.
114+
*/
115+
<T, R = unknown>(options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;
116+
107117
/**
108118
Returns an async iterator.
109119
@@ -150,16 +160,6 @@ export interface GotPaginate {
150160
*/
151161
all: (<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>) => Promise<T[]>)
152162
& (<T, R = unknown>(options?: OptionsWithPagination<T, R>) => Promise<T[]>);
153-
154-
/**
155-
Same as `GotPaginate.each`.
156-
*/
157-
<T, R = unknown>(url: string | URL, options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;
158-
159-
/**
160-
Same as `GotPaginate.each`.
161-
*/
162-
<T, R = unknown>(options?: OptionsWithPagination<T, R>): AsyncIterableIterator<T>;
163163
}
164164

165165
export interface GotRequestFunction {

test/arguments.ts

-10
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,6 @@ test('can omit `url` option if using `prefixUrl`', withServer, async (t, server,
223223
await t.notThrowsAsync(got({}));
224224
});
225225

226-
test('throws TypeError when `options.hooks` is not an object', async t => {
227-
await t.throwsAsync(
228-
// @ts-expect-error Error tests
229-
got('https://example.com', {hooks: 'not object'}),
230-
{
231-
message: 'Expected value which is `predicate returns truthy for any value`, received value of type `Array`.'
232-
}
233-
);
234-
});
235-
236226
test('throws TypeError when known `options.hooks` value is not an array', async t => {
237227
await t.throwsAsync(
238228
// @ts-expect-error Error tests

test/error.ts

-9
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,6 @@ test('`http.request` error through CacheableRequest', async t => {
182182
});
183183
});
184184

185-
test('errors are thrown directly when options.isStream is true', t => {
186-
t.throws(() => {
187-
// @ts-expect-error Error tests
188-
void got('https://example.com', {isStream: true, hooks: false});
189-
}, {
190-
message: 'Expected value which is `predicate returns truthy for any value`, received value of type `Array`.'
191-
});
192-
});
193-
194185
test('normalization errors using convenience methods', async t => {
195186
const url = 'undefined/https://example.com';
196187
await t.throwsAsync(got(url).json().text().buffer(), {message: `Invalid URL: ${url}`});

test/http.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const testIPv6 = (IPv6supported && process.env.TRAVIS_DIST !== 'bionic' && proce
1616
const echoIp: Handler = (request, response) => {
1717
const address = request.connection.remoteAddress;
1818
if (address === undefined) {
19-
return response.end();
19+
response.end();
20+
return;
2021
}
2122

2223
// IPv4 address mapped to IPv6

test/retry.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ test('custom error codes', async t => {
171171
request: () => {
172172
const emitter = new EventEmitter() as http.ClientRequest;
173173
emitter.abort = () => {};
174+
175+
// @ts-expect-error
174176
emitter.end = () => {};
177+
178+
// @ts-expect-error
175179
emitter.destroy = () => {};
176180

177181
const error = new Error('Snap!');
@@ -184,7 +188,7 @@ test('custom error codes', async t => {
184188
},
185189
retry: {
186190
calculateDelay: ({error}) => {
187-
t.is(error.code as string as typeof errorCode, errorCode);
191+
t.is(error.code, errorCode);
188192
return 0;
189193
},
190194
methods: [

0 commit comments

Comments
 (0)