Skip to content
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

Type error when updating event without startDate #441

Open
LaikaTheSpaceDog opened this issue Sep 20, 2023 · 0 comments
Open

Type error when updating event without startDate #441

LaikaTheSpaceDog opened this issue Sep 20, 2023 · 0 comments

Comments

@LaikaTheSpaceDog
Copy link

When updating an existing event, I get a typescript error as it's expecting a startDate to be passed as a parameter even though this field should only be required when creating an event, not updating an existing event.

RNCalendarEvents.saveEvent('Updated: My Event, {
          id,
          notes: 'Foo bar',
        });

Error:

Argument of type '{ id: string; notes: string; }' is not assignable to parameter of type 'CalendarEventWritable'.
  Property 'startDate' is missing in type '{ id: string; notes: string; }' but required in type 'CalendarEventWritable'.ts(2345)

Environment

System:
OS: macOS 13.5.2
CPU: (10) arm64 Apple M1 Pro
Memory: 84.39 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 16.20.0
path: ~/.nvm/versions/node/v16.20.0/bin/node
Yarn: Not Found
npm:
version: 8.19.4
path: ~/.nvm/versions/node/v16.20.0/bin/npm
Watchman:
version: 2023.08.07.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.11.3
path: /Users/oscarwales/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9862592
Xcode:
version: 14.3.1/14E300c
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.11
path: /usr/bin/javac
Ruby:
version: 2.7.4
path: /Users/oscarwales/.rvm/rubies/ruby-2.7.4/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: false
newArchEnabled: false
iOS:
hermesEnabled: false
newArchEnabled: false

Steps to Reproduce

  1. Create an event using:
const [lastCreatedEventId, setLastCreatedEventId] = useState('');

RNCalendarEvents.saveEvent('foo', {
    startDate: new Date().toISOString(),
    calendarId,
}).then((eventId) => setLastCreatedEventId(eventId))
  1. Attempt to then update the event:
RNCalendarEvents.saveEvent('foo: updated', {
    id: lastCreatedEvent,
    notes: 'THIS IS A TEST',
});

Expected Behavior

There should be no type errors

Actual Behavior

Get the following type error:

Argument of type '{ id: string; notes: string; }' is not assignable to parameter of type 'CalendarEventWritable'.
  Property 'startDate' is missing in type '{ id: string; notes: string; }' but required in type 'CalendarEventWritable'.ts(2345)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant