Skip to content

Commit

Permalink
feat: include "lib.dom" to annotate Response
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Oct 12, 2022
1 parent 57def2d commit 6825755
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/InteractiveIsomorphicRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { invariant } from 'outvariant'
import { Response } from '@remix-run/web-fetch'
import { IsomorphicRequest } from './IsomorphicRequest'
import { createLazyCallback, LazyCallback } from './utils/createLazyCallback'

Expand Down
1 change: 0 additions & 1 deletion src/glossary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Response } from '@remix-run/web-fetch'
import type { HeadersObject, Headers } from 'headers-polyfill'
import type { InteractiveIsomorphicRequest } from './InteractiveIsomorphicRequest'
import type { IsomorphicRequest } from './IsomorphicRequest'
Expand Down
2 changes: 0 additions & 2 deletions src/interceptors/ClientRequest/NodeClientRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import type { RequestOptions } from 'http'
import { ClientRequest, IncomingMessage } from 'http'
import { until } from '@open-draft/until'
import { Headers } from 'headers-polyfill'
import { Response } from '@remix-run/web-fetch'
import type { ClientRequestEmitter } from '.'
import { concatChunkToBuffer } from './utils/concatChunkToBuffer'
import {
ClientRequestEndChunk,
normalizeClientRequestEndArgs,
} from './utils/normalizeClientRequestEndArgs'
import { NormalizedClientRequestArgs } from './utils/normalizeClientRequestArgs'
import { getIncomingMessageBody } from './utils/getIncomingMessageBody'
import { bodyBufferToString } from './utils/bodyBufferToString'
import {
ClientRequestWriteArgs,
Expand Down
11 changes: 0 additions & 11 deletions src/interceptors/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,3 @@ export class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
})
}
}

// async function normalizeFetchResponse(
// response: Response
// ): Promise<IsomorphicResponse> {
// return {
// status: response.status,
// statusText: response.statusText,
// headers: objectToHeaders(headersToObject(response.headers)),
// body: await response.text(),
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as path from 'path'
import { pageWith } from 'page-with'
import { HttpServer } from '@open-draft/test-server/http'
import { RequestHandler } from 'express-serve-static-core'
import { createBrowserXMLHttpRequest } from '../../../helpers'
import { IsomorphicRequest, IsomorphicResponse } from '../../../../src'
import { createBrowserXMLHttpRequest, XMLHttpResponse } from '../../../helpers'
import { IsomorphicRequest } from '../../../../src'
import { anyUuid, headersContaining } from '../../../jest.expect'
import { encodeBuffer } from '../../../../src/utils/bufferUtils'

Expand Down Expand Up @@ -55,7 +55,8 @@ test('intercepts an HTTP GET request', async () => {
credentials: 'omit',
_body: encodeBuffer(''),
})
expect(response).toEqual<IsomorphicResponse>({

expect(response).toEqual<XMLHttpResponse>({
status: 200,
statusText: 'OK',
headers: headersContaining({}),
Expand Down Expand Up @@ -85,7 +86,7 @@ test('intercepts an HTTP POST request', async () => {
credentials: 'omit',
_body: encodeBuffer(JSON.stringify({ user: 'john' })),
})
expect(response).toEqual<IsomorphicResponse>({
expect(response).toEqual<XMLHttpResponse>({
status: 200,
statusText: 'OK',
headers: headersContaining({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import * as path from 'path'
import { pageWith } from 'page-with'
import { HttpServer } from '@open-draft/test-server/http'
import { FetchInterceptor } from '../../../../src/interceptors/fetch'
import { listToHeaders } from 'headers-polyfill'
import { FetchInterceptor } from '../../../../src/interceptors/fetch'

declare namespace window {
export const interceptor: FetchInterceptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
import http, { IncomingMessage } from 'http'
import { HttpServer } from '@open-draft/test-server/http'
import { Response } from '@remix-run/web-fetch'
import { HttpRequestEventMap } from '../../../../src'
import { ClientRequestInterceptor } from '../../../../src/interceptors/ClientRequest'

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"moduleResolution": "node",
"removeComments": false,
"esModuleInterop": true,
"downlevelIteration": true
"downlevelIteration": true,
"lib": ["dom", "dom.iterable"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.test.*"]
Expand Down

0 comments on commit 6825755

Please sign in to comment.