[react-native-fabric] Add typings for react-native-fabric

This commit is contained in:
Joseph Roque
2017-11-16 00:19:18 -05:00
parent 08da8b8a66
commit 2d55cdf31e
4 changed files with 103 additions and 0 deletions

70
types/react-native-fabric/index.d.ts vendored Normal file
View File

@@ -0,0 +1,70 @@
// Type definitions for react-native-fabric 0.5
// Project: https://github.com/corymsmith/react-native-fabric
// Definitions by: Joseph Roque <https://github.com/josephroque>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface CustomAttributes {
[key: string]: any;
}
export namespace Answers {
function logCustom(eventName: string, customAttributes?: CustomAttributes): void;
function logInvite(method: string, customAttributes?: CustomAttributes): void;
function logLevelStart(levelName: string, customAttributes?: CustomAttributes): void;
function logLevelEnd(levelName: string, customAttributes?: CustomAttributes): void;
function logLogin(method: string, success: boolean, customAttributes?: CustomAttributes): void;
function logSearch(query: string, customAttributes?: CustomAttributes): void;
function logSignUp(method: string, success: boolean, customAttributes?: CustomAttributes): void;
function logShare(
method: string,
contentName: string,
contentType: string,
contentId: string,
customAttributes?: CustomAttributes): void;
function logStartCheckout(
totalPrice: number,
count: number,
currency: string,
customAttributes?: CustomAttributes): void;
function logAddToCart(
itemPrice: number,
currency: string,
itemName: string,
itemType: string,
itemId: string,
customAttributes?: CustomAttributes): void;
function logPurchase(
itemPrice: number,
currency: string,
success: boolean,
itemName: string,
itemType: string,
itemId: string,
customAttributes?: CustomAttributes): void;
function logContentView(
contentName: string,
contentType: string,
contentId: string,
customAttributes?: CustomAttributes): void;
function logRating(
rating: number,
contentId: string,
contentType: string,
contentName: string,
customAttributes?: CustomAttributes): void;
}
export namespace Crashlytics {
function crash(): void;
function throwException(): void;
function recordError(error: any): void;
function logException(value: string): void;
function log(message: string): void;
function setUserEmail(email: string | null): void;
function setUserIdentifier(id: string | null): void;
function setUserName(userName: string | null): void;
function setBool(key: string, value: boolean): void;
function setNumber(key: string, value: number): void;
function setString(key: string, value: string): void;
function recordCustomExceptionName(name: string, reason: string, stack?: any[]): void;
}

View File

@@ -0,0 +1,7 @@
import { Answers, Crashlytics } from 'react-native-fabric';
Answers.logSearch('query');
Answers.logCustom('event', { customKey: 0 });
Crashlytics.crash();
Crashlytics.setUserName('name');

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-native-fabric-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }