Skip to content

Commit

Permalink
fix(fetch): add HTTPS Agent types to fetch & Request (#78)
Browse files Browse the repository at this point in the history
* fix: add typings for HTTPS agent for fetch and Request (#18)

Co-authored-by: Clifford Fajardo <[email protected]>

* chore: fix changeset

---------

Co-authored-by: Clifford Fajardo <[email protected]>
Co-authored-by: Clifford Fajardo <[email protected]>
Co-authored-by: Irakli Gozalishvili <[email protected]>
  • Loading branch information
4 people authored Aug 28, 2023
1 parent f1d9272 commit c4980f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-poets-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@web-std/fetch": minor
---

expose `RequestExtraOptions` to `fetch` & add `HTTPs.agent` to types
8 changes: 4 additions & 4 deletions packages/fetch/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const supportedSchemas = new Set(['data:', 'http:', 'https:', 'file:']);
* Fetch function
*
* @param {string | URL | import('./request').default} url - Absolute url or Request instance
* @param {RequestInit} [options_] - Fetch options
* @param {RequestInit & import('./request.js').RequestExtraOptions} [options_] - Fetch options
* @return {Promise<import('./response').default>}
*/
async function fetch(url, options_ = {}) {
Expand Down Expand Up @@ -319,9 +319,9 @@ async function fetch(url, options_ = {}) {
}

/**
*
* @param {import('http').ClientRequest} request
* @param {(error:Error) => void} errorCallback
*
* @param {import('http').ClientRequest} request
* @param {(error:Error) => void} errorCallback
*/
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
const LAST_CHUNK = Buffer.from('0\r\n\r\n');
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch/src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const isRequest = object => {
* @property {number} [highWaterMark]
* @property {boolean} [insecureHTTPParser]
*
* @typedef {((url:URL) => import('http').Agent) | import('http').Agent} Agent
* @typedef {((url:URL) => import('http').Agent | import('https').Agent) | import('http').Agent | import('https').Agent} Agent
*
* @typedef {Object} RequestOptions
* @property {string} [method]
Expand Down

0 comments on commit c4980f4

Please sign in to comment.