diff --git a/types/react-radio-group/index.d.ts b/types/react-radio-group/index.d.ts new file mode 100644 index 0000000000..5c3e6092ab --- /dev/null +++ b/types/react-radio-group/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for react-radio-group 3.0 +// Project: https://github.com/chenglou/react-radio-group +// Definitions by: Jason Unger +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; + +export namespace Radio { + type RadioProps = React.InputHTMLAttributes; +} +export const Radio: React.ComponentClass; + +export namespace RadioGroup { + interface RadioGroupProps { + name?: string; + selectedValue?: React.InputHTMLAttributes['value']; + onChange?: (value: React.InputHTMLAttributes['value']) => void; + Component?: string | React.ReactElement>; + } +} +export const RadioGroup: React.ComponentClass; diff --git a/types/react-radio-group/react-radio-group-tests.tsx b/types/react-radio-group/react-radio-group-tests.tsx new file mode 100644 index 0000000000..d34d7d05ff --- /dev/null +++ b/types/react-radio-group/react-radio-group-tests.tsx @@ -0,0 +1,25 @@ +import * as React from 'react'; +import { Radio, RadioGroup } from "react-radio-group"; + +class ReactRadioGroup extends React.Component['value'] }> { + state = { + selectedValue: 2, + }; + + handleChange: RadioGroup.RadioGroupProps['onChange'] = selectedValue => { + console.log(selectedValue); + this.setState({ selectedValue }); + } + + render() { + return ( +
+ + + + + +
+ ); + } +} diff --git a/types/react-radio-group/tsconfig.json b/types/react-radio-group/tsconfig.json new file mode 100644 index 0000000000..615f55eee3 --- /dev/null +++ b/types/react-radio-group/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-radio-group-tests.tsx" + ] +} diff --git a/types/react-radio-group/tslint.json b/types/react-radio-group/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-radio-group/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }