mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add typings for react-native-shared-group-preferences (#45423)
Co-authored-by: Anthony Campbell <acampbell2@officeworks.com.au>
This commit is contained in:
parent
1e67ae1a43
commit
0d58fcc990
16
types/react-native-shared-group-preferences/index.d.ts
vendored
Normal file
16
types/react-native-shared-group-preferences/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for react-native-shared-group-preferences 1.1
|
||||
// Project: https://github.com/KjellConnelly/react-native-shared-group-preferences#readme
|
||||
// Definitions by: Cambo <https://github.com/indentedspace>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface SharedGroupPreferenceOptions {
|
||||
useAndroidSharedPreferences?: boolean;
|
||||
}
|
||||
|
||||
export namespace SharedGroupPreferences {
|
||||
function isAppInstalledAndroid(packageName: string): Promise<void>;
|
||||
function getItem(key: string, appGroup: string, options?: SharedGroupPreferenceOptions): Promise<any>;
|
||||
function setItem(key: string, value: any, appGroup: string, options?: SharedGroupPreferenceOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export default SharedGroupPreferences;
|
||||
@ -0,0 +1,24 @@
|
||||
import SharedGroupPreferences, { SharedGroupPreferenceOptions } from 'react-native-shared-group-preferences';
|
||||
|
||||
const isAppInstalledAndroid = async (packageName: string) => {
|
||||
let appIsInstalled;
|
||||
try {
|
||||
await SharedGroupPreferences.isAppInstalledAndroid(packageName);
|
||||
appIsInstalled = true;
|
||||
} catch (e) {
|
||||
appIsInstalled = false;
|
||||
}
|
||||
|
||||
return appIsInstalled;
|
||||
};
|
||||
|
||||
const getItem = async (key: string, appGroup: string, options: SharedGroupPreferenceOptions) => {
|
||||
const result = await SharedGroupPreferences.getItem(key, appGroup);
|
||||
return result;
|
||||
};
|
||||
|
||||
const setItem = async (key: string, data: any, appGroup: string, options: SharedGroupPreferenceOptions) => {
|
||||
await SharedGroupPreferences.setItem(key, data, appGroup);
|
||||
};
|
||||
|
||||
export default { isAppInstalledAndroid, getItem, setItem };
|
||||
23
types/react-native-shared-group-preferences/tsconfig.json
Normal file
23
types/react-native-shared-group-preferences/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-shared-group-preferences-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-native-shared-group-preferences/tslint.json
Normal file
1
types/react-native-shared-group-preferences/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user