Skip to content

Commit

Permalink
Add @ts-ignore to suppress TypeScript error in model template
Browse files Browse the repository at this point in the history
The added `@ts-ignore` directive resolves a TypeScript error when calling `store.getByField` in the generated model template.
This mostly to achieve a quick fix which should not be the final solution.
The root problem is that Entity and BaseEntity does not allow other types than string for id, so the Compact and CompactEntity are an Omit from Entity with an override of the id field.
  • Loading branch information
jorgecuesta committed Jan 30, 2025
1 parent cef46a8 commit 07f3ca6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/template/model.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class <%= props.className %> implements CompatEntity {
}
}
<% } else { %>static async getBy<%=helper.upperFirst(field.name) %>(<%=field.name %>: <%=field.type %>, options: GetOptions<Compat<%=props.className %>Props>): Promise<<%=props.className %>[]> {
// @ts-ignore
const records = await store.getByField<Compat<%=props.className %>Props>('<%=props.entityName %>', '<%=field.name %>', <%=field.name %>, options);
return records.map(record => this.create(record as unknown as <%= props.className %>Props));
}
Expand Down

0 comments on commit 07f3ca6

Please sign in to comment.