Skip to content

Commit 02d9fdb

Browse files
authored
fix: redefine urllib export types (#5386)
```bash node_modules/.store/[email protected]/node_modules/egg/index.d.ts:63:3 - error TS2666: Exports and export assignments are not permitted in module augmentations. 63 export { HttpClientRequestURL, HttpClientRequestOptions, HttpClientResponse }; ~~~~~~ Found 1 error in node_modules/.store/[email protected]/node_modules/egg/index.d.ts:63 ```
1 parent a612e80 commit 02d9fdb

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ site/dist
3636
.umi-production
3737
.vercel
3838
package-lock.json
39+
.tshy*

index.d.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
HttpClientResponse as HttpClientResponseOld,
2020
} from 'urllib';
2121
import {
22-
RequestURL as HttpClientRequestURL,
23-
RequestOptions as HttpClientRequestOptions,
24-
HttpClientResponse,
22+
RequestURL,
23+
RequestOptions,
24+
HttpClientResponse as HttpClientResponseNext,
2525
} from 'urllib-next';
2626
import {
2727
EggCoreBase,
@@ -60,7 +60,9 @@ declare module 'egg' {
6060
// return await app.httpclient.request(url, options);
6161
// }
6262
// ```
63-
export { HttpClientRequestURL, HttpClientRequestOptions, HttpClientResponse };
63+
export type HttpClientRequestURL = RequestURL;
64+
export type HttpClientRequestOptions = RequestOptions;
65+
export type HttpClientResponse<T = any> = HttpClientResponseNext<T>;
6466
// Compatible with both urllib@2 and urllib@3 RequestOptions to request
6567
export interface EggHttpClient extends EventEmitter {
6668
request<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;

test/fixtures/apps/app-ts/app/controller/foo.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import {
66
EggLogger,
77
EggHttpClient,
88
EggContextHttpClient,
9+
HttpClientRequestURL,
10+
HttpClientRequestOptions as RequestOptionsNext,
911
} from 'egg';
10-
import { RequestOptions as RequestOptionsNext } from 'urllib-next';
1112
import { RequestOptions2, RequestOptions } from 'urllib';
1213

1314
// add user controller and service
@@ -59,8 +60,8 @@ export default class FooController extends Controller {
5960
}
6061
}
6162

62-
async requestWithHttpclientNext(request: RequestOptionsNext) {
63-
let result = await this.app.curl('url', request);
63+
async requestWithHttpclientNext(request: RequestOptionsNext, url?: HttpClientRequestURL) {
64+
let result = await this.app.curl(url ?? 'url', request);
6465
result = await this.ctx.curl('url', request);
6566
result = await this.app.httpclient.curl('url', request);
6667
result = await this.app.httpclient.request('url', request);

0 commit comments

Comments
 (0)