From fdc75e604c2f835c1d9c5f4d52ca09011b0b0310 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Wed, 10 Apr 2019 00:03:25 +0900 Subject: [PATCH] [node] Infer type of value returned by KeyObject.export more accurately --- types/node/crypto.d.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/types/node/crypto.d.ts b/types/node/crypto.d.ts index f06d4d7bf3..2c965279cf 100644 --- a/types/node/crypto.d.ts +++ b/types/node/crypto.d.ts @@ -135,15 +135,18 @@ declare module "crypto" { export type KeyObjectType = 'secret' | 'public' | 'private'; + interface KeyExportOptions { + type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1'; + format: T; + cipher?: string; + passphrase?: string | Buffer; + } + class KeyObject { private constructor(); asymmetricKeyType?: KeyType; - export(options?: { - type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1', - format: KeyFormat, - cipher?: string, - passphrase?: string | Buffer - }): string | Buffer; + export(options: KeyExportOptions<'pem'>): string | Buffer; + export(options?: KeyExportOptions<'der'>): Buffer; symmetricSize?: number; type: KeyObjectType; }