When I include aurelia-fetch-client in my project, I get some errors that I can't resolve. It says that it can't find: Request, Response, Headers, BufferSource, URLSearchParams, as you can see in the following image:
How can I solve that?
When I include aurelia-fetch-client in my project, I get some errors that I can't resolve. It says that it can't find: Request, Response, Headers, BufferSource, URLSearchParams, as you can see in the following image:
How can I solve that?
Share Improve this question edited Oct 12, 2016 at 22:58 Jeremy Danyow 26.4k12 gold badges90 silver badges135 bronze badges asked Aug 24, 2015 at 9:46 Cosmin IonițăCosmin Ioniță 4,0655 gold badges29 silver badges54 bronze badges2 Answers
Reset to default 6Add the typescript definition file for whatwg-fetch:
https://github./borisyankov/DefinitelyTyped/blob/master/whatwg-fetch/whatwg-fetch.d.ts
Here's more info on the fetch spec:
https://developer.mozilla/en-US/docs/Web/API/Fetch_API
Install whatwg-fetch types with typings.
It's possible use typings
to install the whatwg-fetch types.
npm install typings --global
typings install dt~whatwg-fetch --global
The above installs them from DefinitelyTyped (dt
).
Install whatwg-fetch types with npm (TypeScript 2.0).
npm install --save @types/whatwg-fetch
Further Tweaks
Note: TypeScript might still plain that it "Cannot find name 'URLSearchParams'." We can fix that by adding the an interface to one of our typings files. For instance:
custom_typings/adhoc_interfaces.d.ts
interface URLSearchParams {}