Merge pull request #21761 from shssoichiro/react-toastr

Add initial typings for react-toastr
This commit is contained in:
Armando Aguirre
2017-11-28 18:26:51 -08:00
committed by GitHub
4 changed files with 68 additions and 0 deletions

20
types/react-toastr/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for react-toastr 3.0
// Project: https://github.com/tomchentw/react-toastr
// Definitions by: Josh Holmer <https://github.com/shssoichiro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Component, ReactHTML } from 'react';
export class ToastContainer extends Component<{
toastMessageFactory: any;
className?: string;
}> {
error: (message: string, title: string, optionsOverride?: {}) => void;
info: (message: string, title: string, optionsOverride?: {}) => void;
success: (message: string, title: string, optionsOverride?: {}) => void;
warning: (message: string, title: string, optionsOverride?: {}) => void;
clear: () => void;
}
export const ToastMessageAnimated: keyof ReactHTML;
export const ToastMessagejQuery: keyof ReactHTML;

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { ToastContainer, ToastMessageAnimated } from 'react-toastr';
const toastMessageFactory = React.createFactory(ToastMessageAnimated);
class Test extends React.Component {
ref: ToastContainer;
toastRef = (ref: ToastContainer) => {
this.ref = ref;
}
render() {
return (
<ToastContainer
ref={this.toastRef}
toastMessageFactory={toastMessageFactory}
className="toast-top-right"
/>
);
}
}

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-toastr-tests.tsx"
]
}

View File

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