mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-03 06:27:46 +08:00
Add type for react-native-permissions (#24793)
This commit is contained in:
committed by
Mohamed Hegazy
parent
ad0637bfe3
commit
65f148de7d
28
types/react-native-permissions/index.d.ts
vendored
Normal file
28
types/react-native-permissions/index.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Type definitions for react-native-permissions 1.1
|
||||
// Project: https://github.com/yonahforst/react-native-permissions
|
||||
// Definitions by: Vincent Langlet <https://github.com/vincentlanglet>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type Status = 'authorized' | 'denied' | 'restricted' | 'undetermined';
|
||||
|
||||
interface Rationale {
|
||||
title: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
type CheckOptions = string | { type: string };
|
||||
|
||||
type RequestOptions = string | { type: string, rationale?: Rationale };
|
||||
|
||||
interface ReactNativePermissions {
|
||||
canOpenSettings: () => Promise<boolean>;
|
||||
openSettings: () => Promise<any>;
|
||||
getTypes: () => string[];
|
||||
check: (permission: string, options?: CheckOptions) => Promise<Status>;
|
||||
request: (permission: string, options?: RequestOptions) => Promise<Status>;
|
||||
checkMultiple: (permissions: string[]) => Promise<{ [key: string]: string }>;
|
||||
}
|
||||
|
||||
declare const Permissions: ReactNativePermissions;
|
||||
|
||||
export default Permissions;
|
||||
@@ -0,0 +1,9 @@
|
||||
import Permissions from 'react-native-permissions';
|
||||
|
||||
const firstType = Permissions.getTypes()[0];
|
||||
|
||||
Permissions.canOpenSettings().then();
|
||||
Permissions.openSettings().then();
|
||||
Permissions.check('geolocation').then();
|
||||
Permissions.request('geolocation').then();
|
||||
Permissions.checkMultiple(['geolocation', 'notification']).then();
|
||||
23
types/react-native-permissions/tsconfig.json
Normal file
23
types/react-native-permissions/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-permissions-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-native-permissions/tslint.json
Normal file
1
types/react-native-permissions/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user