From 9ce4bbcff838695cba5bfc37e8d934975e50f26f Mon Sep 17 00:00:00 2001 From: Mark Nelissen Date: Mon, 20 May 2019 21:47:00 +0200 Subject: [PATCH] add typings for react-native-form (#35568) * add typings for react-native-form * add typescript version * fix linting issues --- types/react-native-form/index.d.ts | 21 ++++++++++++++++ .../react-native-form-tests.tsx | 22 +++++++++++++++++ types/react-native-form/tsconfig.json | 24 +++++++++++++++++++ types/react-native-form/tslint.json | 1 + 4 files changed, 68 insertions(+) create mode 100644 types/react-native-form/index.d.ts create mode 100644 types/react-native-form/react-native-form-tests.tsx create mode 100644 types/react-native-form/tsconfig.json create mode 100644 types/react-native-form/tslint.json diff --git a/types/react-native-form/index.d.ts b/types/react-native-form/index.d.ts new file mode 100644 index 0000000000..9ff62e0281 --- /dev/null +++ b/types/react-native-form/index.d.ts @@ -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 +// 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 { } diff --git a/types/react-native-form/react-native-form-tests.tsx b/types/react-native-form/react-native-form-tests.tsx new file mode 100644 index 0000000000..ff78e16b0c --- /dev/null +++ b/types/react-native-form/react-native-form-tests.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; +import Form from 'react-native-form'; + +function FormView() { + return
; +} + +const customFields = { + RadioButtons: { + controlled: true, + valueProp: 'selectedOption', + callbackProp: 'onSelection', + } +}; + +function FormViewWithCustomField() { + return
; +} + +function FormViewWithViewProps() { + return
; +} diff --git a/types/react-native-form/tsconfig.json b/types/react-native-form/tsconfig.json new file mode 100644 index 0000000000..550c6660aa --- /dev/null +++ b/types/react-native-form/tsconfig.json @@ -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" + ] +} diff --git a/types/react-native-form/tslint.json b/types/react-native-form/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-form/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }