Add definitions for react-notification-system-redux (#13431)

* Add definitions for react-notification-system-redux

* Add semicolor, add missing compiler option
This commit is contained in:
Karol Janyst 2016-12-28 17:10:10 +01:00 committed by Andy
parent 43751cf91f
commit 08c8f92a86
5 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// Type definitions for react-notification-system-redux 1.0
// Project: https://github.com/gor181/react-notification-system-redux
// Definitions by: Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Component } from "react";
import { Action } from "redux";
import { Attributes, Notification } from "react-notification-system";
export as namespace Notifications;
export = Notifications;
declare class Notifications extends Component<Notifications.NotificationsProps, any> {}
declare namespace Notifications {
export type NotificationsState = Notification[];
export type NotificationLevel = "error" | "warning" | "info" | "success";
export type NotificationsReducer<A extends Action> = (state: NotificationsState, action: A) => NotificationsState;
export type NotificationShow = (opts?: Notification) => Action;
export interface NotificationsProps extends Attributes {
notifications?: Notification[];
}
export const reducer: NotificationsReducer<any>;
export const show: (opts?: Notification, level?: NotificationLevel) => Action;
export const error: NotificationShow;
export const hide: (opts?: Notification | string | number) => Action;
export const info: NotificationShow;
export const success: NotificationShow;
export const warning: NotificationShow;
}

View File

@ -0,0 +1,5 @@
{
"dependencies": {
"redux": "^3.6.0"
}
}

View File

@ -0,0 +1,33 @@
import * as React from "react";
import { createStore, Store } from "redux";
import { Notification } from "react-notification-system";
import * as Notifications from "react-notification-system-redux";
import { reducer, show, hide, info, error, warning, success, NotificationLevel } from "react-notification-system-redux";
class Test extends React.Component<any, any> {
private test () {
const notification: Notification = {
message : "Test"
};
info(notification);
error(notification);
warning(notification);
success(notification);
show(notification, "info");
show(notification, "error");
show(notification, "warning");
show(notification, "success");
hide(notification);
hide("uid");
hide(123);
}
public render () {
const notifications: Notification[] = [];
return (<Notifications notifications={ notifications } />);
}
}
const store: Store<any> = createStore(reducer)

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-notification-system-redux-tests.tsx"
]
}

View File

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