Added definitions for react-dynamic-number npm package (#23165)

* feat(ReactDynamicNumber): added definitions for RDN

* feat(ReactDynamicNumber): fix validation and linter

* feat(ReactDynamicNumber): PR remarks corrected
This commit is contained in:
Eugene Rodin
2018-01-26 08:59:01 -08:00
committed by Andy
parent 45457bbbc9
commit b66d7c92ce
4 changed files with 68 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for react-dynamic-number 1.7
// Project: https://github.com/uhlryk/react-dynamic-number
// Definitions by: Eugene Rodin <https://github.com/eugrdn>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
/**
* remove Diff & Omit when in will be placed in TS from scratch
*/
export type Diff<T extends string, U extends string> = ({[P in T]: P} & {[P in U]: never} & {[x: string]: never})[T];
export type Omit<T, K extends keyof T> = {[P in Diff<keyof T, K>]: T[P]};
export type BaseInputProps = Partial<
Omit<
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
'ref' | 'value' | 'onChange' | 'placeholder'
>
>;
export interface DynamicNumberProps extends BaseInputProps {
value?: number | '';
separator?: '.' | ',';
thousand?: boolean | ' ';
integer?: number;
fraction?: number;
positive?: boolean;
negative?: boolean;
placeholder?: string;
onChange?: (event: React.ChangeEvent<HTMLInputElement>, modelValue: number, viewValue: string) => void;
}
export default class DynamicNumber extends React.Component<DynamicNumberProps> {}
@@ -0,0 +1,16 @@
import * as React from 'react';
import DynamicNumber from 'react-dynamic-number';
export class Test extends React.Component {
render() {
return (
<DynamicNumber
separator={','}
thousand={' '}
integer={40}
fraction={2}
negative={false}
/>
);
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"strictFunctionTypes": true
},
"files": ["index.d.ts", "react-dynamic-number-tests.tsx"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }