From c3a35a070440b1253c172a0e5e4be0a018206946 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 26 Apr 2022 17:53:54 +0800 Subject: [PATCH] fix(cli): generated type def on multi impl blocks --- cli/src/build.ts | 6 +++++- examples/napi/__test__/typegen.spec.ts.md | 1 + examples/napi/__test__/typegen.spec.ts.snap | Bin 2924 -> 2937 bytes examples/napi/index.d.ts | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index 6ac79586..1cfc33c0 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -592,7 +592,11 @@ async function processIntermediateTypeFile( }) break case 'impl': - impls.set(def.name, `${def.js_doc}${def.def}`) + const existed = impls.get(def.name) + impls.set( + def.name, + `${existed ? existed + '\n' : ''}${def.js_doc}${def.def}`, + ) break case 'interface': dts += diff --git a/examples/napi/__test__/typegen.spec.ts.md b/examples/napi/__test__/typegen.spec.ts.md index 30492b9a..a1ef7ede 100644 --- a/examples/napi/__test__/typegen.spec.ts.md +++ b/examples/napi/__test__/typegen.spec.ts.md @@ -217,6 +217,7 @@ Generated by [AVA](https://avajs.dev). export type Blake2bHasher = Blake2BHasher␊ /** Smoking test for type generation */␊ export class Blake2BHasher {␊ + static withKey(key: Blake2bKey): Blake2BHasher␊ update(data: Buffer): void␊ }␊ export type Blake2bKey = Blake2BKey␊ diff --git a/examples/napi/__test__/typegen.spec.ts.snap b/examples/napi/__test__/typegen.spec.ts.snap index 00747f191b817573755d69c5d831665c075e2707..2fedede7bbd1cd05d7f3c76d4b9c06f82f15c2ff 100644 GIT binary patch literal 2937 zcmV-<3x@PTRzV8rB8_x z803zc&mW5j00000000B68trb|$T4kE6!5=$gKdf;R3In*2!d2dY{;^m*okGsmYW=W z#$`pWq>U*q!(G}|eFl1O(BJ)2+&y6*p)%TlF+eK$^DjX_75)Cn$3Hy! z(WRIjm4lDzDy}P&HKL61Bv2%RZYmq1&_gP{g z25ICgE+WvM`Y4h>dW{xo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rHF%~-Rd)!xJTvq}oLCv2I{A^r>DfK_5q1*pt#g(vegB789=eiCR;PR25o-qRZ4Z z_5Vw64{SR;6ao8{$^Bv$!C|tdtz`?xYUGSDnAqMf9XSt4NY{l|J(}&bq=r9TEG%EDjHQZ>SCo0TQ7Sdom%qEiD{@+ zb4;Z~YfHzIIUO(cVdsPesn2Tfs3xtgkf-F6E}pPv5y_`)8m}|kC$swr^1+vs;{YA} z394Tf29hX2hLEMwVaWY9k`Xv&y9W9Ye#eAQV*o{-h(jLX{(O#8de7NyU97m{DE%q1 z8}TU(^U<1~vq5I0W?Lu4{3GHeyzFR@Je`_cjd|2L$DlbIUV+&zrRCNfAxa>V1Hz0< z8N|iFP?BIb+}FVkNjTKdRyC&ph1HAh=2}krmUgq|RQv?$9Br0U{9gAg#4(yLrc)Lv zvyX>kO~R()GbjK3&%ghv_mREpiJ((nI@XoRa1TMEBn)u7BgR^sma9{9+Sg$2dQhrA zkopsvfLibyDUKWSB}n%rg_46wgQX@^k?i9&*bI|C1!u6Iufti#fPHsHCFWX2`CjJmk>pvxNtUpxAH&S627@{CjbC&)|jgR diff --git a/examples/napi/index.d.ts b/examples/napi/index.d.ts index 909980ed..12fdd1a9 100644 --- a/examples/napi/index.d.ts +++ b/examples/napi/index.d.ts @@ -207,6 +207,7 @@ export class Bird { export type Blake2bHasher = Blake2BHasher /** Smoking test for type generation */ export class Blake2BHasher { + static withKey(key: Blake2bKey): Blake2BHasher update(data: Buffer): void } export type Blake2bKey = Blake2BKey