Last active
July 3, 2019 20:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example", | |
"version": "0.0.0", | |
"description": "", | |
"main": "example", | |
"scripts": { | |
"watch": "tsc" | |
}, | |
"dependencies": { | |
"node-fetch": "^2.6.0", | |
"@types/node-fetch": "^2.3.7" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"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