From 5df7911e84053b4b1e88e95ca858ea58eed74ce7 Mon Sep 17 00:00:00 2001 From: Lucas Bordignon Date: Mon, 28 Sep 2020 09:19:42 -0300 Subject: [PATCH] Add Typescript module definition --- index.d.ts | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..d89fc254 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,94 @@ +declare module "react-native-health" { + export interface HealthKitPermissions { + permissions: { + read: string[]; + write: string[]; + }; + } + export interface MindfulSessionData { + startDate?: Date; + endDate?: Date; + limit?: number; + } + + export interface AppleHealthKit { + initHealthKit( + permissions: HealthKitPermissions, + callback: (error: string, result: Object) => void + ): void; + + saveFood( + options: Object, + callback: (error: string, result: Object) => void + ): void; + + isAvailable(callback: (error: Object, results: boolean) => void): void; + + getDateOfBirth( + options: any, + callback: (error: Object, results: HealthDateOfBirth) => void + ): void; + + getLatestHeight( + options: HealthUnitOptions, + callback: (err: string, results: HealthValue) => void + ): void; + + getLatestWeight( + options: HealthUnitOptions, + callback: (err: string, results: HealthValue) => void + ): void; + + getMindfulSession( + options: MindfulSessionData, + callback: (err: string, results: HealthValue) => void + ): void; + + getStepCount( + options: any, + callback: (err: string, results: HealthValue) => void + ): void; + } + + export interface HealthDateOfBirth { + value: string; + age: number; + } + + export interface HealthValue { + value: number; + startDate: string; + endDate: string; + } + + export interface HealthUnitOptions { + unit: HealthUnit; + } + + export enum HealthUnit { + bpm = "bpm", + calorie = "calorie", + celsius = "celsius", + count = "count", + day = "day", + fahrenheit = "fahrenheit", + foot = "foot", + gram = "gram", + hour = "hour", + inch = "inch", + joule = "joule", + meter = "meter", + mgPerdL = "mgPerdL", + mile = "mile", + minute = "minute", + mmhg = "mmhg", + mmolPerL = "mmolPerL", + percent = "percent", + pound = "pound", + second = "second" + } + + const appleHealthKit: AppleHealthKit; + + export default appleHealthKit; +}