Skip to content

Commit

Permalink
fix: Add 'as any' to create.
Browse files Browse the repository at this point in the history
This should fix #838 which I believe only happens in complicated
schemas.
  • Loading branch information
stephenh committed Jul 29, 2023
1 parent bf6b51a commit 1308fad
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2091,19 +2091,17 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri
if (ctx.options.useExactTypes) {
chunks.push(code`
create<I extends ${utils.Exact}<${utils.DeepPartial}<${fullName}>, 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" : "_";

Expand Down

0 comments on commit 1308fad

Please sign in to comment.