sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

There is no typings for http-cache-semantics options #1370

Closed javierblancosp closed 4 years ago

javierblancosp commented 4 years ago

Describe the bug

The options of the cache providers are not in Got typing. I can do a contribution if it's needed ;)

Actual behavior

Options from https://github.com/kornelski/http-cache-semantics used by https://github.com/lukechilds/cacheable-request are not reflected on got typing options but still are available to use it and useful.

Expected behavior

Have the cache options on got type definition

Code to reproduce

const LRU = require('quick-lru');
const cacheInstance = new LRU({ maxSize: 5 });

got.get('url.com',{
 shared: false,
 cache: cacheInstance
})

Checklist

sindresorhus commented 4 years ago

That's intentional. Anything not in TS types or documented are not guaranteed to be stable.

Share what options you need and we can consider officially exposing them.

javierblancosp commented 4 years ago

:O, basically the only one we were using right now is the 'shared' property from https://github.com/kornelski/http-cache-semantics to allow some particular cases for shared cache. The other properties, I think are not that important.

szmarczak commented 4 years ago

~Also the options aren't request options. These are constructor options that are passed to CachePolicy.~ Please open an issue at cacheable-request.

Edit: indeed the constructor options are the same as request options.

javierblancosp commented 4 years ago

m but correct me if I'm wrong but, if cacheable-request add this properties in their typing, won't also be available on Got. The two things will be needed no, add it on cacheable-request, and also got should extend from it or put it in another property as you prefer.

szmarczak commented 4 years ago

got should extend from it

That's what should be done.

javierblancosp commented 4 years ago

Yep, so there is already a type for that package 'https://www.npmjs.com/package/@types/http-cache-semantics' should I create a PR to extends from that?

szmarczak commented 4 years ago

Yep, feel free. Alternatively you can fetch the arguments from cacheable-request and use these instead. That would work too.