From 0fd7e1bc6fa780fae3c0d7aca9fb58e75ae12937 Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 2 Jan 2019 02:41:21 +0800 Subject: [PATCH] [react-native-modal-dropdown] Add definitions (#31735) * react-native-modal-dropdown: initial definitions * fix the project path and export class * fix member-access --- types/react-native-modal-dropdown/index.d.ts | 44 +++++++++++++++++++ .../react-native-modal-dropdown-tests.tsx | 10 +++++ .../react-native-modal-dropdown/tsconfig.json | 25 +++++++++++ types/react-native-modal-dropdown/tslint.json | 3 ++ 4 files changed, 82 insertions(+) create mode 100644 types/react-native-modal-dropdown/index.d.ts create mode 100644 types/react-native-modal-dropdown/react-native-modal-dropdown-tests.tsx create mode 100644 types/react-native-modal-dropdown/tsconfig.json create mode 100644 types/react-native-modal-dropdown/tslint.json diff --git a/types/react-native-modal-dropdown/index.d.ts b/types/react-native-modal-dropdown/index.d.ts new file mode 100644 index 0000000000..01470ec1cf --- /dev/null +++ b/types/react-native-modal-dropdown/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for react-native-modal-dropdown 0.6 +// Project: https://github.com/sohobloo/react-native-modal-dropdown +// Definitions by: Carlos Li +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +import ModalDropdown = RNModalDropdown.ModalDropdown; +export = ModalDropdown; + +declare namespace RNModalDropdown { + interface PositionStyle { + left?: number; + right?: number; + width?: number; + } + interface ModalDropdownProps { + disabled?: boolean; + defaultIndex?: number; + defaultValue?: string; + options?: any[]; + animated?: boolean; + showsVerticalScrollIndicator?: boolean; + style?: any; + textStyle?: any; + dropdownStyle?: any; + dropdownTextStyle?: any; + dropdownTextHighlightStyle?: any; + adjustFrame?: (positionStyle: PositionStyle) => void; + renderRow?: (option: any, index: number, isSelected: boolean) => any; + renderSeparator?: () => any; + renderButtonText?: (text: any) => any; + onDropdownWillShow?: () => boolean; + onDropdownWillHide?: () => boolean; + onSelect?: (index: number, option: any) => void; + accessible?: boolean; + keyboardShouldPersistTaps?: "always" | "never" | "handled"; + } + + class ModalDropdown extends React.Component { + static default: typeof ModalDropdown; + } +} diff --git a/types/react-native-modal-dropdown/react-native-modal-dropdown-tests.tsx b/types/react-native-modal-dropdown/react-native-modal-dropdown-tests.tsx new file mode 100644 index 0000000000..685dd1f531 --- /dev/null +++ b/types/react-native-modal-dropdown/react-native-modal-dropdown-tests.tsx @@ -0,0 +1,10 @@ +import * as React from 'react'; +import ModalDropdown from "react-native-modal-dropdown"; + +class Test extends React.Component { + render() { + return ( + + ); + } +} diff --git a/types/react-native-modal-dropdown/tsconfig.json b/types/react-native-modal-dropdown/tsconfig.json new file mode 100644 index 0000000000..9800a11341 --- /dev/null +++ b/types/react-native-modal-dropdown/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-native-modal-dropdown-tests.tsx" + ] +} diff --git a/types/react-native-modal-dropdown/tslint.json b/types/react-native-modal-dropdown/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/react-native-modal-dropdown/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}