Skip to content

Typings do not match exported values #418

@zbarbuto

Description

@zbarbuto

Describe the bug
As an example, HealthActivity is exported as an enum (rather than just a type) when no such value exists.

To Reproduce

This gives no TypeScript errors, since HealthActivity is reported as an exported enum.

import AppleHealthKit, {HealthActivity} from 'HealthActivity';

AppleHealthKit.saveWorkout({
 type: HealthActivity.Boxing,
  // other options
});

Instead you get a runtime error "Cannot read property 'Boxing' of undefined" (since the actual value that needs to be referenced is exported under Constants at Constants.Activities.Boxing

Expected behavior

Either HealthActivity (and similar values HealthUnits, HealthObserver and HealthPermission should be converted to Types so that using them as values gives the appropriate TypeSCript error "'HealthActivity' only refers to a type, but is being used as a value here."

Or, the typings should be updated to expose the correct export Constants showing that the actual value to be used is e.g. Constants.Acitivities.Boxing

import AppleHealthKit, {Constants} from 'HealthActivity';

AppleHealthKit.saveWorkout({
 type: Constants.Activities.Boxing,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions