Skip to content

Broken type compatibility with node v24.7.0 and higher #554

@mrkvon

Description

@mrkvon

Summary

I use some node:crypto methods (webcrypto) to handle some key-related logic alongside fedify.
When I upgrade @types/node to version >=24.7.0, I start seeing type errors.

This is likely an incompatibility between types used by Fedify (Deno or DOM), and Node.js, which introduces crypto.subtle.decapsulateBits in v24.7.0.

Workaround

  • Don't upgrade @types/node beyond v24.6.2, or
  • Assert results of methods from node:crypto e.g. (await crypto.subtle.importKey(/*....*/)) as CryptoKey.

This issue is not pressing.

Expected Behavior

I'd expect these type errors not to be present.

Actual Behavior

I use some node:crypto methods (webcrypto) to handle some key-related logic.
When I upgrade @types/node to version >=24.7.0, I start seeing type errors like:

error TS2345: Argument of type '(ctx: Context<ContextData>) => Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; }[]>' is not assignable to parameter of type 'ActorKeyPairsDispatcher<ContextData>'.
  Type 'Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; }[]>' is not assignable to type 'CryptoKeyPair[] | Promise<CryptoKeyPair[]>'.
    Type 'Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; }[]>' is not assignable to type 'Promise<CryptoKeyPair[]>'.
      Type '{ privateKey: CryptoKey; publicKey: CryptoKey; }[]' is not assignable to type 'CryptoKeyPair[]'.
        Type '{ privateKey: webcrypto.CryptoKey; publicKey: CryptoKey; }' is not assignable to type 'CryptoKeyPair'.
          The types of 'privateKey.usages' are incompatible between these types.
            Type 'import("node:crypto").webcrypto.KeyUsage[]' is not assignable to type 'KeyUsage[]'.
              Type 'import("node:crypto").webcrypto.KeyUsage' is not assignable to type 'KeyUsage'.
                Type '"decapsulateBits"' is not assignable to type 'KeyUsage'.

61   .setKeyPairsDispatcher(async ctx => {

Environment

OS: Arch Linux
Runtime: Node.js v25

This is a type error, not a runtime error.

Logs / Screenshots

No response

Steps to Reproduce

tbd if needed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions