Repository: mswjs/msw (ts)

Issue:
Typescript error when using default resolver
### Prerequisites

- [x] I confirm my issue is not in the [opened issues](https://github.com/mswjs/msw/issues)
- [x] I confirm the [Frequently Asked Questions](https://mswjs.io/docs/faq) didn't contain the answer to my issue

### Environment check

- [x] I'm using the [latest](https://github.com/mswjs/msw/releases/latest) `msw` version
- [x] I'm using Node.js version 20 or higher

### Node.js version

v23.7.0

### MSW version

v2.8.4

### Reproduction repository

https://www.typescriptlang.org/play/?jsx=0&ts=5.8.3#code/JYWwDg9gTgLgBAbzgCRjMAlApgZ0gOxywBo4ALNMUmATzCxUuzwkK2YgBsA3LKOAL5wAZlAgg4AchA4A7pIDcAKBVYAHpFgiArvgDGMYK3IBDfABNOWACImYJgIra+NABRK4nuFFxdeUAH4ALkZ0ZgIiDh4+AB58LH9SeMS4HBgoYHwAcwA+JQBKRA8vPVY0uHMsYRNtThgo-zgAXjhXQqac0MxcCKwAOgoQTldJGPNgbhyYXBgYgHpxycl85S9vLBhtKHxySj6sjZG5sDsySVIfHD8+OACAiqqauoa+FaUBJSA

### Reproduction steps

I have the following code with default resolver 
```ts
export function handleDataQuery(
    resolver?: HttpResponseResolver<never, never, string>
) {
    const defaultResolver = () => HttpResponse.html('<div>test</div>');
    return http.get('/path', resolver ?? defaultResolver);
}
```

### Current behavior

Typescript error - 
```
Argument of type 'HttpResponseResolver<never, never, string> | (() => Response)' is not assignable to parameter of type 'HttpResponseResolver<never, never, string>'.
  Type '() => Response' is not assignable to type 'HttpResponseResolver<never, never, string>'.
    Type 'Response' is not assignable to type 'AsyncResponseResolverReturnType<string>'.
      Property '[bodyType]' is missing in type 'Response' but required in type 'HttpResponse<string>'.(2345)
HttpResponse-CSWX6ahe.d.ts(149, 14): '[bodyType]' is declared here.
```

### Expected behavior

Type should be inferred correctly. 

Pull request:
fix(HttpResponse): strictly annotate all response methods
- Fixes #2506

## Motivation

Previously, some of the `HttpResponse` class methods returned a plain `Response` instance. It meant that `HttpResponse.html()` returns a plain `Response`, which made it type-incompatible with signatures like `HttpResponseResolver<never, never, string>`. That's incorrect.

Patch:
diff --git a/src/core/HttpResponse.ts b/src/core/HttpResponse.ts
index ca4e698b..611f5edc 100644
--- a/src/core/HttpResponse.ts
+++ b/src/core/HttpResponse.ts
@@ -116,7 +116,7 @@ export class HttpResponse<
   static xml<BodyType extends string>(
     body?: BodyType | null,
     init?: HttpResponseInit,
-  ): Response {
+  ): HttpResponse<BodyType> {
     const responseInit = normalizeResponseInit(init)
 
     if (!responseInit.headers.has('Content-Type')) {
@@ -135,7 +135,7 @@ export class HttpResponse<
   static html<BodyType extends string>(
     body?: BodyType | null,
     init?: HttpResponseInit,
-  ): Response {
+  ): HttpResponse<BodyType> {
     const responseInit = normalizeResponseInit(init)
 
     if (!responseInit.headers.has('Content-Type')) {
@@ -157,7 +157,7 @@ export class HttpResponse<
   static arrayBuffer(
     body?: ArrayBuffer | SharedArrayBuffer,
     init?: HttpResponseInit,
-  ): Response {
+  ): HttpResponse<ArrayBuffer | SharedArrayBuffer> {
     const responseInit = normalizeResponseInit(init)
 
     if (!responseInit.headers.has('Content-Type')) {
@@ -168,7 +168,7 @@ export class HttpResponse<
       responseInit.headers.set('Content-Length', body.byteLength.toString())
     }
 
-    return new HttpResponse(body as ArrayBuffer, responseInit)
+    return new HttpResponse(body, responseInit)
   }
 
   /**
@@ -179,7 +179,10 @@ export class HttpResponse<
    *
    * HttpResponse.formData(data)
    */
-  static formData(body?: FormData, init?: HttpResponseInit): Response {
+  static formData(
+    body?: FormData,
+    init?: HttpResponseInit,
+  ): HttpResponse<FormData> {
     return new HttpResponse(body, normalizeResponseInit(init))
   }
 }


Test patch:
diff --git a/test/typings/regressions/default-resolver-type.test-d.ts b/test/typings/regressions/default-resolver-type.test-d.ts
new file mode 100644
index 00000000..ba9abfa9
--- /dev/null
+++ b/test/typings/regressions/default-resolver-type.test-d.ts
@@ -0,0 +1,11 @@
+/**
+ * @see https://github.com/mswjs/msw/issues/2506
+ */
+import { http, HttpResponse, HttpResponseResolver } from 'msw'
+
+it('supports a union of the matching explicit and implicit response resolvers', () => {
+  function handle(resolver?: HttpResponseResolver<never, never, string>) {
+    const defaultResolver = () => HttpResponse.html('<div>test</div>')
+    http.get('/path', resolver || defaultResolver)
+  }
+})