When using (await got.post().json()).data in TypeScript it gives the error Property 'data' does not exist on type 'unknown'.
Note: This is a complier error, the code runs without issue, but the compile-time type checker isn't happy.
Expected behavior
I would expect that the code wouldn't error, without me having to resort to using // @ts-ignore or writing a custom interface to conform the returned object to.
Code to reproduce
// <snip>
const res = await got
.post("<url>", { body: form, headers })
.json();
return res.data; // <-- error is here
Checklist
[x] I have read the documentation.
[x] I have tried my code with the latest version of Node.js and Got.
Describe the bug
Actual behavior
When using
(await got.post().json()).data
in TypeScript it gives the errorProperty 'data' does not exist on type 'unknown'
. Note: This is a complier error, the code runs without issue, but the compile-time type checker isn't happy.Expected behavior
I would expect that the code wouldn't error, without me having to resort to using
// @ts-ignore
or writing a custom interface to conform the returned object to.Code to reproduce
Checklist