| 4cc9a197 | 07-Aug-2023 |
Pierre Zimmermann <[email protected]> |
BREAKING CHANGE(expo-calendar): forbid passing an id to createEventAsync and updateEventAsync (#23810)
Co-authored-by: pierrezimmermann <[email protected]>
Co-authored-by: Łukasz Kosmaty <kosmatyluk
BREAKING CHANGE(expo-calendar): forbid passing an id to createEventAsync and updateEventAsync (#23810)
Co-authored-by: pierrezimmermann <[email protected]>
Co-authored-by: Łukasz Kosmaty <[email protected]>
# Why
<!--
Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests.
-->
I noticed that the `eventData` param of the `createEventAsync` method from `expo-calendar` can have an `id` property but it's not used in the code. What I found out is that we the id will be generated by the OS calendar system so we can't choose it. I think the typing should reflect the fact that id is not used so it should not be allowed to pass an `eventData` object with an `id` property. This is also true for the `updateEventAsync` method.
This is a breaking change only when these methods are used with object litterals
```tsx
// This will work
const eventData = {
title: 'title',
id: '1',
}
updateEventAsync(eventId, eventData);
// This will trigger an error
updateEventAsync(eventId, {
title: 'title',
id: '1',
});
```
So it doesn't fully prevent passing ids but the type and the docs will indicate that these methods don't do anything with an id if provided
# How
I updated the typing of `eventData` param of `createEventAsync` and `updateEventAsync` methods to `Omit<Partial<Event>, 'id'>`
<!--
How did you build this feature or fix this bug and why?
-->
# Test Plan
I checked that there was no typescript error in the places where these methods are used.
<!--
Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction.
-->
# Checklist
<!--
Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules.
-->
Regarding documentation update I'm not very sure. From what I have understood it should update itself automatically based on the API so there should not be any change needed. When running the docs website locally though I didn't see my changes but I guess it doesn't use my local version?
- [X] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
- [X] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [X] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin).
show more ...
|