From a78577801ead189c9fd87c29ff33c835f8d518df Mon Sep 17 00:00:00 2001 From: Karol Majewski Date: Sat, 19 Jan 2019 01:57:44 +0100 Subject: [PATCH] [rc-switch] Add new definition --- types/rc-switch/index.d.ts | 24 +++++++++++++++++++++++ types/rc-switch/rc-switch-tests.ts | 31 ++++++++++++++++++++++++++++++ types/rc-switch/tsconfig.json | 24 +++++++++++++++++++++++ types/rc-switch/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/rc-switch/index.d.ts create mode 100644 types/rc-switch/rc-switch-tests.ts create mode 100644 types/rc-switch/tsconfig.json create mode 100644 types/rc-switch/tslint.json diff --git a/types/rc-switch/index.d.ts b/types/rc-switch/index.d.ts new file mode 100644 index 0000000000..3327b693f7 --- /dev/null +++ b/types/rc-switch/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for rc-switch 1.8 +// Project: http://github.com/react-component/switch +// Definitions by: Karol Majewski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface Props { + autoFocus?: boolean; + checked?: boolean; + checkedChildren: React.ReactNode; + className?: string; + defaultChecked?: boolean; + disabled?: boolean; + loadingIcon?: React.ReactNode; + onChange?: (checked: boolean) => void; + onClick?: (checked: boolean) => void; + prefixCls?: string; + tabIndex?: number; + unCheckedChildren: React.ReactNode; +} + +export default class Switch extends React.Component {} diff --git a/types/rc-switch/rc-switch-tests.ts b/types/rc-switch/rc-switch-tests.ts new file mode 100644 index 0000000000..e1a8f498ff --- /dev/null +++ b/types/rc-switch/rc-switch-tests.ts @@ -0,0 +1,31 @@ +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import Switch, { Props } from 'rc-switch'; + +/** + * Only required props. + */ +React.createElement(Switch, { + checkedChildren: 'hello', + disabled: false, + onChange: console.log, + unCheckedChildren: 'world' +}); + +/** + * All accepted props. + */ +React.createElement(Switch, { + autoFocus: false, + checked: false, + checkedChildren: 'hello', + className: 'switch', + defaultChecked: false, + disabled: false, + loadingIcon: 0, + onChange: console.log, + onClick: console.log, + prefixCls: 'rc-', + tabIndex: 0, + unCheckedChildren: 'world', +}); diff --git a/types/rc-switch/tsconfig.json b/types/rc-switch/tsconfig.json new file mode 100644 index 0000000000..41320f2d09 --- /dev/null +++ b/types/rc-switch/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "rc-switch-tests.ts" + ] +} diff --git a/types/rc-switch/tslint.json b/types/rc-switch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rc-switch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }