Skip to content

Fix TypeScript 5.9 compatibility issues with BufferSource types #423

Closed

Description

@dahlia

Problem

GitHub Actions workflows are failing due to type errors after Deno automatically upgraded to version 2.5, which includes TypeScript 5.9.2. The type errors occur when passing Uint8Array<ArrayBufferLike> to functions expecting BufferSource.

Error details

The following type errors are occurring in packages/fedify/src/runtime/key.ts:

Argument of type 'Uint8Array<ArrayBufferLike>' is not assignable to parameter of type 'BufferSource'.
  Type 'Uint8Array<ArrayBufferLike>' is not assignable to type 'ArrayBufferView<ArrayBuffer>'.
    Types of property 'buffer' are incompatible.
      Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'.
        Type 'SharedArrayBuffer' is missing the following properties from type 'ArrayBuffer': 
        resizable, resize, detached, transfer, transferToFixedLength

Affected lines:

  • Line 42: crypto.subtle.importKey() with "pkcs8" format
  • Line 114: crypto.subtle.importKey() with "spki" format
  • Line 122: crypto.subtle.importKey() with "raw" format

Root cause

  • Deno 2.5 upgraded TypeScript from 5.8.3 to 5.9.2
  • TypeScript 5.9 includes changes to lib.d.ts that make ArrayBufferLike and ArrayBuffer types incompatible
  • The new ArrayBuffer type in TypeScript 5.9 includes additional properties that SharedArrayBuffer doesn't have

Solution

Instead of downgrading Deno, we should fix the type compatibility issues properly. The Uint8Array instances need to be cast or ensured to use ArrayBuffer instead of ArrayBufferLike when passed to Web Crypto API methods.

References

Activity

  1. added theissue type on Sep 11, 2025
  2. changed the issue type fromtoon Sep 11, 2025
  3. dodok8 commented on Sep 11, 2025

    @dodok8
    Member

    Line 36 was also affected. I'd like to handle this issue.

  4. dodok8 commented on Sep 11, 2025

    @dodok8
    Member

    Currently, I'm working on this branch: https://github.com/dodok8/fedify/tree/dodok8-issue-399

    However, federation/kv.test.ts is failing on my local machine

      await t.step("set() & get()", async () => {
        await store.set(["foo", "bar"], "foobar");
        assertEquals(await store.get(["foo", "bar"]), "foobar");
        assertEquals(await store.get(["foo"]), undefined);
    
        await store.set(["foo", "baz"], "baz", {
          ttl: Temporal.Duration.from({ seconds: 0 }),
        });
        assertEquals(await store.get(["foo", "baz"]), undefined);
      });

    assertEquals(await store.get(["foo", "baz"]), undefined); failed with value "baz", which means the ttl options don't work properly. It's another issue anyway; it makes the test fail.

    EDIT: After adding await new Promise((resolve) => setTimeout(resolve, 1000)); between 15 and 16, the overall test passed.

  5. added
    upstreamIssues caused by upstream dependencies
    on Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

Urgent

Effort

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions