Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[email protected]: crypto/KeyFormat declarations require the global JsonWebKey, breaking Node-only type-checks

Aperta
#10,115 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@effect-bot ci sta già lavorando.

Dal 29/10/2026.

  • #10116 di @skyaara — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

What version of Effect is running?
  • Effect: 4.1.0. Not reproducible with 4.0.7. The declaration is unchanged on main at dae6428.
  • TypeScript: 7.0.2, 6.0.3 and 5.9.3
  • @types/node: 26.6.4
  • Node.js: 24.20.0
What steps can reproduce the bug?

Create these files in an otherwise empty directory.

package.json:

{
  "private": true,
  "type": "module",
  "dependencies": {
    "effect": "4.1.0"
  },
  "devDependencies": {
    "@types/node": "26.6.4",
    "typescript": "7.0.2"
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2024",
    "module": "NodeNext",
    "lib": ["ES2024"],
    "types": ["node"],
    "strict": true,
    "noEmit": true
  },
  "include": ["src/**/*.ts"]
}

src/repro.ts:

import type * as Effect from "effect/Effect"

export type Probe = Effect.Effect<void>

Run:

npm install
npx tsc --project tsconfig.json
What is the expected behavior?

The import type-checks with Node's declarations, as it does on 4.0.7. This is the same configuration as #8745, which was fixed for TextDecoderOptions.

What do you see instead?
node_modules/effect/dist/crypto/KeyFormat.d.ts(122,51): error TS2304: Cannot find name 'JsonWebKey'.

KeyFormat.jwk is typed with the global JsonWebKey. TypeScript's DOM library declares that global, but @types/node does not: Node declares the type only as webcrypto.JsonWebKey inside node:crypto.

Schema imports crypto/KeyFormat, so the error appears for imports of effect, effect/Effect and effect/Schema without using any crypto API. It is the only unresolved name in this configuration. Adding DOM to lib, enabling skipLibCheck, or declaring a global JsonWebKey makes the reproduction pass.

Additional information
Proposed fix

Declare the RFC 7517 shape in KeyFormat instead of relying on the global, and use it in place of JsonWebKey throughout the module:

/**
 * A JSON Web Key (RFC 7517) as the Web Crypto API reads and writes it.
 */
export interface JsonWebKey {
  alg?: string
  crv?: string
  d?: string
  dp?: string
  dq?: string
  e?: string
  ext?: boolean
  k?: string
  key_ops?: Array<string>
  kty?: string
  n?: string
  oth?: Array<{ d?: string; r?: string; t?: string }>
  p?: string
  q?: string
  qi?: string
  use?: string
  x?: string
  y?: string
}

The members match the DOM library's JsonWebKey and Node's webcrypto.JsonWebKey. With TypeScript 5.9.3, 6.0.3 and 7.0.2, under strict and exactOptionalPropertyTypes, a standalone check that this interface is assignable to and from the DOM global and webcrypto.JsonWebKey, and is accepted by and returned from crypto.subtle.importKey("jwk", …) and crypto.subtle.exportKey("jwk", …), passes with Node types only, DOM types only, and both.

The proposed change has not been tested inside Effect's own build or test suite. The open effect/jose PR (#9883) also uses the global JsonWebKey, so it may need the same treatment.

Current workaround

A dependency patch that replaces JsonWebKey at dist/crypto/KeyFormat.d.ts:122 with the structural type above.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
11h 11m
PR unite (30g)
840

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.