add typings for react-native-form (#35568)

* add typings for react-native-form

* add typescript version

* fix linting issues
This commit is contained in:
Mark Nelissen
2019-05-20 12:47:00 -07:00
committed by Ryan Cavanaugh
parent 43ddae1d7d
commit 9ce4bbcff8
4 changed files with 68 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for react-native-form 2.1
// Project: https://github.com/julianocomg/react-native-form#readme
// Definitions by: Mark Nelissen <https://github.com/marknelissen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.4
import { Component } from 'react';
import { ViewProps } from 'react-native';
export interface FormProps extends ViewProps {
customFields?: {
[key: string]: {
callbackProp: string;
controlled: boolean;
valueProp: string;
}
};
ref: string;
}
export default class Form extends Component<FormProps> { }
@@ -0,0 +1,22 @@
import * as React from 'react';
import Form from 'react-native-form';
function FormView() {
return <Form ref="form"></Form>;
}
const customFields = {
RadioButtons: {
controlled: true,
valueProp: 'selectedOption',
callbackProp: 'onSelection',
}
};
function FormViewWithCustomField() {
return <Form ref="form" customFields={customFields}></Form>;
}
function FormViewWithViewProps() {
return <Form ref="form" style={{ flex: 1 }}></Form>;
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-native-form-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }