Repository navigation
feat(core): add support for readonly attribute arrays - #18186
Conversation
📝 WalkthroughWalkthroughChangelog entries are removed across multiple packages. Core package type signatures for model hooks are updated to accept Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Do you mind if we do that in #18185? I'll update that this evening |
|
Of course! I'll keep it uncommitted locally instead :) |
* main: (200 commits) meta: update actions/upload-artifact action to v7.0.1 (sequelize#18212) meta: update sequelize AUTHORS (sequelize#18208) feat(cli): add migration generate, run, status & undo (sequelize#18193) feat(core): Drop the ability to specify the dialect as a string (sequelize#18204) feat: update some dialect adapters (sequelize#18189) feat(postgres): replace pg-hstore with inline hstore parser (sequelize#18151) feat(core): add `sql.random`, improve `Order` typing (sequelize#18203) meta: use Sequelize Bot for drafting PRs (sequelize#18201) meta: automatically mark unfinished PRs as draft (sequelize#18197) meta: update dependency @oclif/test to v4.1.18 (sequelize#18198) fix(core): replace @typeparam with @template in JSDoc (sequelize#18094) feat(core): Add support for UUID v7 (sequelize#17832) meta: update sequelize AUTHORS (sequelize#18190) meta: update dependency @oclif/plugin-help to ^6.2.43 (sequelize#18195) meta: update dependency esbuild to v0.28.0 (sequelize#18192) meta: update dependency @oclif/plugin-help to ^6.2.42 (sequelize#18191) meta: update dependency @oclif/core to ^4.10.5 (sequelize#18187) meta: update sequelize AUTHORS (sequelize#18158) feat: add Node 24 support, drop Node 18 (sequelize#18185) feat(core): add support for readonly attribute arrays (sequelize#18186) ...
expect-type's `toEqualTypeOf` now uses TypeScript's own type identity, and `.parameter()`/`.returns` cover every overload of a function. The type tests are adjusted accordingly: - The hook parameter tests (#12959) check that the parameters extend their writable version, which is what catches readonly arrays. The writable helper treats the Sequelize classes that hook options may contain (Transaction, Association, AbstractQuery, SQL expressions) as opaque, and allows readonly attribute lists (#18186). The find hooks are declared with `WritableDeep<FindOptions>` since #18186 and their options are too large for expect-type, so they are no longer checked. - The `set` and `previous` assertions in the model type tests list the parameter and return types of every overload. Co-Authored-By: Claude Fable 5.1 <[email protected]>
expect-type's `toEqualTypeOf` now uses TypeScript's own type identity, and `.parameter()`/`.returns` cover every overload of a function. The type tests are adjusted accordingly: - The hook parameter tests (#12959) check that the parameters extend their writable version, which is what catches readonly arrays. The writable helper treats the Sequelize classes that hook options may contain (Transaction, Association, AbstractQuery, SQL expressions) as opaque, and allows readonly attribute lists (#18186). The find hooks are declared with `WritableDeep<FindOptions>` since #18186 and their options are too large for expect-type, so they are no longer checked. - The `set` and `previous` assertions in the model type tests list the parameter and return types of every overload. Co-Authored-By: Claude Fable 5.1 <[email protected]>
expect-type's `toEqualTypeOf` now uses TypeScript's own type identity, and `.parameter()`/`.returns` cover every overload of a function. The type tests are adjusted accordingly: - The hook parameter tests (#12959) check that the parameters extend their writable version, which is what catches readonly arrays. The writable helper treats the Sequelize classes that hook options may contain (Transaction, Association, AbstractQuery, SQL expressions) as opaque, and allows readonly attribute lists (#18186). The find hooks are declared with `WritableDeep<FindOptions>` since #18186 and their options are too large for expect-type, so they are no longer checked. - The `set` and `previous` assertions in the model type tests list the parameter and return types of every overload. Co-Authored-By: Claude Fable 5.1 <[email protected]>
expect-type's `toEqualTypeOf` now uses TypeScript's own type identity, and `.parameter()`/`.returns` cover every overload of a function. The type tests are adjusted accordingly: - The hook parameter tests (#12959) check that the parameters extend their writable version, which is what catches readonly arrays. The writable helper treats the Sequelize classes that hook options may contain (Transaction, Association, AbstractQuery, SQL expressions) as opaque, and allows readonly attribute lists (#18186). The find hooks are declared with `WritableDeep<FindOptions>` since #18186 and their options are too large for expect-type, so they are no longer checked. - The `set` and `previous` assertions in the model type tests list the parameter and return types of every overload. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Pull Request Checklist
Description of Changes
This is just a tiny typing change to allow the
attributesarray to be readonly.We never mutate that array, so it should not cause an issue.
List of Breaking Changes
beforeFindhooks has been changed fromFindOptionstoWritableDeep<FindOptions>beforeCounthas been changed fromCountOptionstoWritableDeep<CountOptions>Summary by CodeRabbit
Chores
Refactor