Add definitions for react-maskedinput (#13430)

* Add definitions for react-maskedinput

* Add tslint.json

* Add required compiler option

* Add flag to compile against typescript 2.1

* Add semicolon, remove ts 2.1 target
This commit is contained in:
Karol Janyst
2016-12-28 17:09:04 +01:00
committed by Andy
parent 614610c58d
commit 43751cf91f
4 changed files with 76 additions and 0 deletions

32
react-maskedinput/index.d.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
// Type definitions for react-maskedinput 3.3
// Project: https://github.com/insin/react-maskedinput
// Definitions by: Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ComponentClass, HTMLAttributes } from "react";
export as namespace MaskedInput;
export = MaskedInput;
declare const MaskedInput: MaskedInput;
type MaskedInput = ComponentClass<MaskedInput.MaskedInputProps>;
declare namespace MaskedInput {
export interface FormatCharacter {
validate(char: string): string;
transform?(char: string): string;
}
export interface CharsFormatters {
[char: string]: FormatCharacter;
}
export interface MaskedInputProps extends HTMLAttributes<any> {
mask: string;
formatCharacter?: CharsFormatters;
placeholderChar?: string;
}
}

View File

@@ -0,0 +1,22 @@
import * as React from "react"
import * as MaskedInput from "react-maskedinput"
class Test extends React.Component<any, any> {
public render () {
return (
<MaskedInput mask="111"
placeholderChar="X"
formatCharacter={
{
"a" : {
validate: (char: string) => char,
transform: (char: string) => char
}
}
} />
)
}
}

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"react-maskedinput-tests.tsx"
]
}

View File

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