Create definitions for react-radio-group

This commit is contained in:
Jason Unger
2018-05-14 17:41:17 -04:00
parent 03a4f2840f
commit beb66996a4
4 changed files with 72 additions and 0 deletions

22
types/react-radio-group/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for react-radio-group 3.0
// Project: https://github.com/chenglou/react-radio-group
// Definitions by: Jason Unger <https://github.com/jsonunger>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as React from 'react';
export type Value = React.InputHTMLAttributes<HTMLInputElement>['value'];
export type RadioProps = React.InputHTMLAttributes<HTMLInputElement>;
export const Radio: React.ComponentClass<RadioProps>;
export interface RadioGroupProps {
name?: string;
selectedValue?: Value;
onChange?: (value: Value) => void;
Component?: string | React.ReactElement<React.HTMLProps<HTMLElement>>;
}
export const RadioGroup: React.ComponentClass<RadioGroupProps>;

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import { Radio, RadioGroup, RadioGroupProps, Value } from "react-radio-group";
class ReactRadioGroup extends React.Component<RadioGroupProps> {
constructor(props: RadioGroupProps) {
super(props);
}
handleChange(value: Value) {
console.log(value);
}
render() {
return (
<div>
<RadioGroup name="radioGroup" onChange={this.handleChange} selectedValue={2}>
<Radio id="Option A" value="a" />
<Radio id="Option B" value={2} />
<Radio id="Option C" value={["hello"]} disabled />
</RadioGroup>
</div>
);
}
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }