diff --git a/src/index.ts b/src/index.ts index 3bee259..5e9f114 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,12 @@ function toTypeScriptTypeX(type: XtpNormalizedType): string { case 'buffer': return nullify('ArrayBufferLike') case 'object': - return nullify((type as ObjectType).name) + const oType = (type as ObjectType) + if (oType.properties?.length > 0) { + return nullify(oType.name) + } else { + return nullify('any') + } case 'enum': return nullify((type as EnumType).name) case 'map': diff --git a/template/src/pdk.ts.ejs b/template/src/pdk.ts.ejs index f4977be..16018f6 100644 --- a/template/src/pdk.ts.ejs +++ b/template/src/pdk.ts.ejs @@ -128,7 +128,7 @@ export function <%- imp.name %>(<%- imp.input ? `input: ${toTypeScriptType(imp.i <% if (imp.input) { -%> <% if (isJsonEncoded(imp.input)) { -%> <% if (isObject(imp.input)) { %> - const casted = <%- castingFunction(imp.input.xtpType, 'From') %>(input) + const casted = cast(<%- castExpression(imp.input.xtpType, 'From') %>, input) const mem = Memory.fromJsonObject(casted) <% } else { %> const mem = Memory.fromJsonObject(input as any) @@ -150,7 +150,7 @@ export function <%- imp.name %>(<%- imp.input ? `input: ${toTypeScriptType(imp.i <% if (isJsonEncoded(imp.output)) { -%> <% if (isObject(imp.output)) { -%> const output = Memory.find(ptr).readJsonObject(); - return <%- castingFunction(imp.output.xtpType, 'To') %>(output) + return cast(<%- castExpression(imp.output.xtpType, 'To') %>, output) <% } else { -%> return Memory.find(ptr).readJsonObject(); <% } -%>