Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#10,115 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@effect-bot ya está trabajando en esto.

Desde el 29/10/2026.

  • #10116 de @skyaara — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
16.7k
Forks
808
Merge medio
11 h 11 min
PR fusionados (30 d)
840

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Effect-TS/effect

Todos los issues de Effect-TS/effect

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.