Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/mswPublic

Commitf40515b

Browse files
Slessikettanaito
andauthored
fix(HttpResponse): preserve request body type after cloning the request (#2600)
Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
1 parentfee715c commitf40515b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

‎src/core/HttpResponse.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type DefaultUnsafeFetchResponse = Response & {
1717

1818
exportinterfaceStrictRequest<BodyTypeextendsJsonBodyType>extendsRequest{
1919
json():Promise<BodyType>
20+
clone():StrictRequest<BodyType>
2021
}
2122

2223
/**

‎test/typings/http.test-d.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ it('supports null as the request body type argument', () => {
7171
})
7272
})
7373

74+
it('returns the same request type when cloning',()=>{
75+
http.post<never,{id:string}>('/user',async({ request})=>{
76+
constdata=awaitrequest.clone().json()
77+
78+
expectTypeOf(data).toEqualTypeOf<{id:string}>()
79+
})
80+
81+
http.post<never,null>('/user',async({ request})=>{
82+
constdata=awaitrequest.clone().json()
83+
84+
expectTypeOf(data).toEqualTypeOf<null>()
85+
})
86+
})
87+
7488
it('returns plain Response without explicit response body type argument',()=>{
7589
http.get('/user',()=>{
7690
returnnewResponse('hello')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp