Skip to content

Commit

Permalink
fix: resolve type error by explicitly typing headers as HeadersInit (#…
Browse files Browse the repository at this point in the history
…3009)

* fix: resolve type error by explicitly typing headers as HeadersInit

This commit addresses a type error in `src/utils/ccip.ts` where the `headers` object was not assignable to the `HeadersInit` type. The issue occurred due to the optional `'Content-Type'` property. Explicitly typing `headers` as `HeadersInit` resolves the type incompatibility, ensuring compatibility with the `fetch` API.

- Explicitly typed `headers` as `HeadersInit`.
- Resolved the optional `'Content-Type'` property type conflict.
- Verified functionality by running the test suite.

This fix improves type safety and aligns with TypeScript's strict requirements.

* Create fast-timers-crash.md

---------

Co-authored-by: jxom <[email protected]>
  • Loading branch information
vijaypushkin and jxom authored Nov 16, 2024
1 parent c5ba028 commit b57213a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fast-timers-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Resolved type error by explicitly typing `headers` as `HeadersInit` in CCIP.
2 changes: 1 addition & 1 deletion src/utils/ccip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export async function ccipRequest({
const url = urls[i]
const method = url.includes('{data}') ? 'GET' : 'POST'
const body = method === 'POST' ? { data, sender } : undefined
const headers =
const headers: HeadersInit =
method === 'POST' ? { 'Content-Type': 'application/json' } : {}

try {
Expand Down

0 comments on commit b57213a

Please sign in to comment.