Skip to content

Breaking change note for Typed Services #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions content/releases/3.breaking-changes/2.version-11.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ title: Version 11
description: Breaking changes may require action on your part before upgrading.
---

## Version 11.10.0

#### Typed services for API extensions using TypeScript

The services exposed to API extensions using TypeScript are now fully typed instead of `any`, which may cause new type errors when building extensions.

Arguments of service methods are now strictly typed, which can result in type errors for broader types that would not error before:
- The ItemsService constructor now expects the collection name to be a `string` and will error on `string | undefined` (or other unions).
- Similarly, functions like `service.readOne()`/`service.readMany()` now expect `string | number` for their primary keys and will error for nullable types

::callout{icon="material-symbols:info-outline"}
**Workaround**
:::collapsible{name="type workarounds"}
If you encounter type errors, you can cast the services to `any` to restore the previous behavior:

```ts
export default defineHook(({ filter, action }, context) => {
const { services, database: knex, getSchema, logger } = context;
const { ItemsService, FieldsService } = services as any;

...
});
```
:::
::

## Version 11.9.0

#### SDK login function now uses a payload parameter for email and password
Expand Down