From 90ee6baac4e5203b7f5e2f3323bf848d05efcd53 Mon Sep 17 00:00:00 2001 From: Heather Booker Date: Fri, 3 Nov 2017 11:04:12 -0400 Subject: [PATCH] Add types for react-numeric-input (#21151) --- types/react-numeric-input/index.d.ts | 46 +++++++++++++++++++ .../react-numeric-input-tests.tsx | 8 ++++ types/react-numeric-input/tsconfig.json | 24 ++++++++++ types/react-numeric-input/tslint.json | 1 + 4 files changed, 79 insertions(+) create mode 100644 types/react-numeric-input/index.d.ts create mode 100644 types/react-numeric-input/react-numeric-input-tests.tsx create mode 100644 types/react-numeric-input/tsconfig.json create mode 100644 types/react-numeric-input/tslint.json diff --git a/types/react-numeric-input/index.d.ts b/types/react-numeric-input/index.d.ts new file mode 100644 index 0000000000..e6121f45e7 --- /dev/null +++ b/types/react-numeric-input/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for react-numeric-input 2.2 +// Project: https://github.com/vlad-ignatov/react-numeric-input#readme +// Definitions by: Heather Booker +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; + +export = NumericInput; + +declare namespace NumericInput { + interface NumericInputProps extends React.Props { + addLabelText?: string; + className?: string; + defaultValue?: number | string; + disabled?: boolean; + format?: ((s: string) => string); + max?: number | ((v: number) => number); + maxLength?: number; + min?: number | ((v: number) => number); + mobile?: boolean | 'auto' | ((this: NumericInput) => any); // TODO: fix `any` + noValidate?: boolean| string; + onBlur?: React.FocusEventHandler; + onChange?: ((v: number, s: string, i: JSX.Element) => void); + onFocus?: React.FocusEventHandler; + onInput?: ((...args: any[]) => void); + onInvalid?: ((err: string, v: number, s: string) => void); + onKeyDown?: React.KeyboardEventHandler; + onSelect?: ((...args: any[]) => void); + onValid?: ((v: number, s: string) => void); + parse?: ((s: string) => number | string); + pattern?: string; + precision?: number | ((this: NumericInput) => void); + readOnly?: boolean; + required?: boolean; + size?: number | string; + snap?: boolean; + step?: number | object; // TODO: should be `number | ` + strict?: boolean; + style?: { [key: string]: { [key: string]: string } } | boolean; + type?: string; + value?: number | string; + } +} + +declare class NumericInput extends React.Component {} diff --git a/types/react-numeric-input/react-numeric-input-tests.tsx b/types/react-numeric-input/react-numeric-input-tests.tsx new file mode 100644 index 0000000000..b3921c5e21 --- /dev/null +++ b/types/react-numeric-input/react-numeric-input-tests.tsx @@ -0,0 +1,8 @@ +import { Component } from 'react'; +import * as NumericInput from 'react-numeric-input'; + +export class NumericInputTest extends Component { + render() { + return(); + } +} diff --git a/types/react-numeric-input/tsconfig.json b/types/react-numeric-input/tsconfig.json new file mode 100644 index 0000000000..65c483475e --- /dev/null +++ b/types/react-numeric-input/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "preserve", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-numeric-input-tests.tsx" + ] +} diff --git a/types/react-numeric-input/tslint.json b/types/react-numeric-input/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-numeric-input/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }