fix(fetch): accept a named interface as request body without a cast
FetchOptions['body'] listed `Record<string, unknown>`, which a named interface is not assignable to (interfaces carry no implicit index signature), so every caller passing a typed body had to cast it. Widen the object member to `object`: named interfaces and arrays now assign directly, `any` is not introduced, and bare primitives (number/boolean) are still rejected. Runtime is unchanged — the serializer already narrows the body with its own casts. Guard it with a type test (src/types.test-d.ts, run under vitest --typecheck): a named interface must assign to the body type and flow through the method shortcuts with no cast, while bare primitives stay rejected. Enable typecheck for the package's vitest project so the assertions are enforced by tsc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,5 +3,11 @@ import { defineConfig } from 'vitest/config';
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
// Type tests (*.test-d.ts) are statically analyzed with `tsc --noEmit`
|
||||
// alongside the runtime suite.
|
||||
typecheck: {
|
||||
enabled: true,
|
||||
tsconfig: './tsconfig.src.json',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user