Skip to content

Commit

Permalink
Add index fields type guards (#145)
Browse files Browse the repository at this point in the history
* Add type guard for at least one field in an index

* Added `@ts-expect-error` to fix field index type error
  • Loading branch information
NuroDev authored Feb 18, 2025
1 parent 6306951 commit f3f662c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export type ModelIndex<
/**
* The list of fields in the model for which the index should be created.
*/
fields: Array<ModelIndexField<T>>;
fields: [ModelIndexField<T>, ...Array<ModelIndexField<T>>];
/**
* The identifier of the index.
*/
Expand Down
1 change: 1 addition & 0 deletions tests/meta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,7 @@ test('try to create new index without fields', () => {
index: {
slug: 'indexSlug',
unique: true,
// @ts-expect-error This property already includes a strict type guard
fields: [],
},
},
Expand Down

0 comments on commit f3f662c

Please sign in to comment.