From 1f64f9fbf3c9c36ea0f3a843a4754443d2d37daa Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 21 Nov 2021 18:23:53 +0800 Subject: [PATCH] fix(cli): ExternalObject type decalare --- cli/src/build.ts | 10 +++++++--- examples/napi/__test__/typegen.spec.ts.md | 10 +++++++--- examples/napi/__test__/typegen.spec.ts.snap | Bin 1246 -> 1251 bytes examples/napi/index.d.ts | 8 ++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index d590ede1..f859b56c 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -344,9 +344,13 @@ async function processIntermediateTypeFile( .split('\n') .map((line) => line.trim()) .filter(Boolean) - let dts = `export class ExternalObject { - private readonly __type: unique symbol; - [val: unique symbol]: T + let dts = `/* eslint-disable */ + +export class ExternalObject { + readonly '': { + readonly '': unique symbol + [K: symbol]: T + } }\n` const classes = new Map() const impls = new Map() diff --git a/examples/napi/__test__/typegen.spec.ts.md b/examples/napi/__test__/typegen.spec.ts.md index 7dc78975..a4bbe485 100644 --- a/examples/napi/__test__/typegen.spec.ts.md +++ b/examples/napi/__test__/typegen.spec.ts.md @@ -8,9 +8,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - `export class ExternalObject {␊ - private readonly __type: unique symbol;␊ - [val: unique symbol]: T␊ + `/* eslint-disable */␊ + ␊ + export class ExternalObject {␊ + readonly '': {␊ + readonly '': unique symbol␊ + [K: symbol]: T␊ + }␊ }␊ export const DEFAULT_COST: number␊ export function getWords(): Array␊ diff --git a/examples/napi/__test__/typegen.spec.ts.snap b/examples/napi/__test__/typegen.spec.ts.snap index f471018bb26f538d14e59b84d635b1162dcab231..1f203965fd0ddd087c2edd1c9813617fa118fbf3 100644 GIT binary patch literal 1251 zcmV<91RVQ8RzV5LYJ6;Xh{1IT3P2?mtWV7o;#9@V2E7UVnwtLg=Hr+jOOvr2S z3h)rz5E6IJyaGqgRQGtC@%+TmiX5Dp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UY-(;0rxy?LHj-l4{0V z55X(Y=XM4=;U<`~dCZ&5W%Z$*g@2}Lyq@7puqk#Qk?6LMt4HWJDWV9wWlcV>8g>lZ zL#SM$*w7X58yYmhv`f-RCEB{*>Z6t+1S{?M@F||h`xDi=M0qU@>Q3(`gdI? z@c#$CF4Z)8B|`WZIt0rqzp ItW^#G09@vE7XSbN diff --git a/examples/napi/index.d.ts b/examples/napi/index.d.ts index cad9c2dc..7bbbe23e 100644 --- a/examples/napi/index.d.ts +++ b/examples/napi/index.d.ts @@ -1,6 +1,10 @@ +/* eslint-disable */ + export class ExternalObject { - private readonly __type: unique symbol; - [val: unique symbol]: T + readonly '': { + readonly '': unique symbol + [K: symbol]: T + } } export const DEFAULT_COST: number export function getWords(): Array