Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Module d.ts file

// Enables using module in typescript react-native projects,
// with editor auto-complete and type-validation (in VS Code)

// See:
// Typescript docs:
// https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html
// Typescript Playground, for automatic generation of .d.ts file from .js:
// https://www.typescriptlang.org/play?filetype=js&useJavaScript=true#code/Q
// Simplest approach:
// https://stackoverflow.com/a/51355583

declare module "react-native-barometer";

interface BarometerPayload { // See module README for field descriptions
timestamp:number,
pressure:number,
altitudeASL:number,
altitude:number,
relativeAltitude:number,
verticalSpeed:number,
};

type BarometerWatchCallbackFn = (payload:BarometerPayload) => void;

declare namespace Barometer { // See module README for function descriptions
function isSupported(): Promise<boolean>;
function setInterval(interval: number): void;
function setLocalPressure(pressure: number): void;
function watch(success: BarometerWatchCallbackFn): number;
function clearWatch(watchID: any): void;
function stopObserving(): void;
}

export {
BarometerPayload,
BarometerWatchCallbackFn
};

export default Barometer;