TS error: property 'responseType' are incompatible? #2264
-
vscode ts error: |
Beta Was this translation helpful? Give feedback.
Answered by
sindresorhus
Oct 11, 2025
Replies: 1 comment
-
|
The issue is that TypeScript infers const options = {
method: method,
searchParams: merged,
timeout: 6000,
responseType: 'json' as const,
resolveBodyOnly: true,
json: null
};This tells TypeScript to treat Also, you probably don't need |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sindresorhus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is that TypeScript infers
responseType: 'json'as typestringinstead of the literal type'json'. The fix is to useas conston just that property:This tells TypeScript to treat
'json'as the specific literal type instead of the broaderstringtype, which is what Got's types expect.Also, you probably don't need
json: nullif you're not sending a JSON body - you can just omit it entirly.