react-native-health icon indicating copy to clipboard operation
react-native-health copied to clipboard

Casting permissions object to HealthKitPermissions in .js causing troubles

Open asjustis opened this issue 2 years ago • 1 comments

Describe the bug Might be something simple, but in a fresh project, I get an error using the sample code from the Readme. In particular, the issue is the as HealthKitPermissions below:

/* Permission options */
const permissions = {
  permissions: {
    read: [AppleHealthKit.Constants.Permissions.HeartRate],
    write: [AppleHealthKit.Constants.Permissions.Steps],
  },
} as HealthKitPermissions;

I use plain Javascript RN build, and added this code to App.js (naturally, the whole sample with the imports), and got the following error in the VS Code:

any(implicit)
(alias) interface HealthKitPermissions
import HealthKitPermissions
Unexpected identifier, expected the end of an expression statement (`;`)Flow(ParseError)

Installing Flow didn't help, Prettier does not like it either, and the build displays a runtime error too ('Parsing error: Missing semicolon.' one)

Any help is more than welcome!

To Reproduce Steps to reproduce the behavior:

  1. Fresh build of React Native
  2. Install react-native-health lib
  3. Add sample code from the 'Usage' section into App.js
  4. See the following error (VS Code)

Screenshots

Screenshot 2022-11-03 at 16 49 12 Screenshot 2022-11-03 at 16 49 34 Screenshot 2022-11-03 at 16 49 50 Screenshot 2022-11-03 at 16 50 03

Expected behavior No errors

asjustis avatar Nov 03 '22 14:11 asjustis

If you tsx your js file, the problem will be fixed.

alpcesur avatar Nov 07 '22 13:11 alpcesur