[email protected]: crypto/KeyFormat declarations require the global JsonWebKey, breaking Node-only type-checks
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
What version of Effect is running?
- Effect:
4.1.0. Not reproducible with4.0.7. The declaration is unchanged onmainat dae6428. - TypeScript:
7.0.2,6.0.3and5.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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
@effect/ai-anthropic: text_editor_20250728 insert decodes `new_str`, but the API sends `insert_text`Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
sql-pg: send several statements in one extended-query Sync (transaction-local context without extra round trips)Forse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#10113 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
CircuitBreaker: record an outcome without guarding the callForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#10110 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
CopilotKit/openmuse#215 ·
I maintainer di solito rispondono entro 3 giorni
-
b:minor bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
software-mansion/argent#1698 ·
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno