You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When you use the saveMindfulSession method, the options argument is typed as HealthValueOptions. This typing makes the value property required and the startTime and endTime properties optional.
To Reproduce
Steps to reproduce the behavior:
Create a function that inits the AppleHealthKit with write permissions for MindfulSession.
import AppleHealthKit, {
HealthValue,
HealthKitPermissions,
HealthInputOptions,
HealthValueOptions,
HealthUnit,
} from 'react-native-health'
/* Permission options */
const permissions = {
permissions: {
write: [AppleHealthKit.Constants.Permissions.MindfulSession],
},
} as HealthKitPermissions
export function trackMindfulMinutes(
startDate: string | undefined,
endDate: string | undefined,
) {
AppleHealthKit.initHealthKit(permissions, (error: string) => {
/* Called after we receive a response from the system */
if (error) {
console.log('[ERROR] Cannot grant permissions!')
}
let options: HealthValueOptions = {
startDate: startDate,
endDate: endDate,
}
console.log(options)
AppleHealthKit.saveMindfulSession(
options,
(err: Object, results: HealthValue) => {
if (err) {
console.error(err)
return {
err,
}
}
console.log(results)
return results
},
)
})
}
Notice the unsatisfied type error on options:
Property 'value' is missing in type '{ startDate: string | undefined; endDate: string | undefined; }' but required in type 'HealthValueOptions'.
Add the value and remove the start and end date props.
Run this method passing just a value.
See the error:
{"message": "startDate and endDate are required in options"}
Expected behavior
I would expect the options type to align with the requirements of the underlying native module. If the values prop hasn't been implemented yet, it shouldn't be a required property.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Device: iPhone 13 Simulator
OS: iOS16
The text was updated successfully, but these errors were encountered:
Describe the bug
When you use the
saveMindfulSession
method, theoptions
argument is typed asHealthValueOptions.
This typing makes thevalue
property required and thestartTime
andendTime
properties optional.To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect the options type to align with the requirements of the underlying native module. If the
values
prop hasn't been implemented yet, it shouldn't be a required property.Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: