Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aurelia-fetch-client.d.ts undefined symbols

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:

enter image description here

How can I solve that?

like image 201
Cosmin Ioniță Avatar asked Aug 24 '15 09:08

Cosmin Ioniță


2 Answers

Add the typescript definition file for whatwg-fetch:

https://github.com/borisyankov/DefinitelyTyped/blob/master/whatwg-fetch/whatwg-fetch.d.ts

Here's more info on the fetch spec:

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

like image 122
Jeremy Danyow Avatar answered Oct 21 '22 01:10

Jeremy Danyow


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 complain 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 {}
like image 33
Shaun Luttin Avatar answered Oct 21 '22 02:10

Shaun Luttin