Skip to content

Instantly share code, notes, and snippets.

@HerrZatacke
Last active July 3, 2019 20:12
Show Gist options
  • Save HerrZatacke/ae90f608e042864b6e00e9c73a950602 to your computer and use it in GitHub Desktop.
Save HerrZatacke/ae90f608e042864b6e00e9c73a950602 to your computer and use it in GitHub Desktop.
Type 'Response' is missing the following properties from type 'Response': redirected, trailer, formData
example.ts:9:11 - error TS2345: Argument of type '(response: Response) => PromiseLike<object>' is not assignable to parameter of type '(value: Response) => object | PromiseLike<object>'.
Types of parameters 'response' and 'value' are incompatible.
Type 'Response' is missing the following properties from type 'Response': redirected, trailer, formData
9 .then(toJson)
~~~~~~
[21:58:53] Found 1 error. Watching for file changes.
import fetch from 'node-fetch';
const toJson = (response: Response):PromiseLike<object> => (
response.json()
);
const makeSomeRequest = (): Promise<object> => {
return fetch('https://some-api.com/')
.then(toJson)
};
makeSomeRequest();
{
"name": "example",
"version": "0.0.0",
"description": "",
"main": "example",
"scripts": {
"watch": "tsc"
},
"dependencies": {
"node-fetch": "^2.6.0",
"@types/node-fetch": "^2.3.7"
}
}
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"outDir": "lib/",
"watch": true,
"esModuleInterop": true
},
"include": [
"example.ts"
],
"exclude": [
"node_modules/"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment