diff --git a/src/main.ts b/src/main.ts index bbfaedbad..8efce8ac2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2091,19 +2091,17 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri if (ctx.options.useExactTypes) { chunks.push(code` create, I>>(base?: I): ${fullName} { + return ${fullName}.fromPartial(base ?? ({} as any)); + }, `); } else { chunks.push(code` create(base?: ${utils.DeepPartial}<${fullName}>): ${fullName} { + return ${fullName}.fromPartial(base ?? {}); + }, `); } - chunks.push(code` - return ${fullName}.fromPartial(base ?? {}) - `); - - chunks.push(code`},`, code``); - // create the fromPartial function declaration const paramName = messageDesc.field.length > 0 ? "object" : "_";