Skip to content

Commit 498c67f

Browse files
authored
Fix type for Response.json() (#86)
1 parent a20699b commit 498c67f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ declare namespace LightMyRequest {
7979
trailers: { [key: string]: string }
8080
payload: string
8181
body: string
82-
json: () => object
82+
json: () => any
8383
cookies: Array<object>
8484
}
8585

test/index.test-d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ expectType<Chain>(inject(dispatch))
7575
expectType<Chain>(inject(dispatch, { method: 'get', url: '/' }))
7676
// @ts-ignore tsd supports top-level await, but normal ts does not so ignore
7777
expectType<Response>(await inject(dispatch, { method: 'get', url: '/' }))
78+
79+
type ParsedValue = { field: string }
80+
// @ts-ignore tsd supports top-level await, but normal ts does not so ignore
81+
const response: Response = await inject(dispatch)
82+
const parsedValue: ParsedValue = response.json()
83+
expectType<ParsedValue>(parsedValue)

0 commit comments

Comments
 (0)