linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
566 stars 146 forks source link

fetcher forces use of Headers type in request options #446

Closed ludwigschub closed 3 years ago

ludwigschub commented 4 years ago

To achieve https://github.com/solid/solid-spec/blob/master/api-rest.md#creating-containers-directories

one can do the following in Javascript:

const request = {
  headers: {
    Slug: 'Untitled Folder',
    Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
    'Content-Type': 'text/turtle',
  },
};

return this.fetcher.webOperation('POST', folderAddress, request);

However in typescript this is not possible because the headers type of Record<string, string> is not assignable to fetchers' AutoInitOptions that extend RequestInit and force the use of Headers type instead of Headers | Record<string, string> | string[][]

Is there a specific reason why headers was overwritten in AutoInitOptions? I get errors when using the Headers constructor for the headers and I would like to use the more loose typing of headers again...