Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions types/react-notification-system/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
import * as React from "react";

declare namespace NotificationSystem {

export interface System extends React.Component<Attributes, State> {
addNotification(notification: Notification): Notification;
removeNotification(uidOrNotification: number | string | Notification): void;
clearNotifications(): void;
editNotification(uidOrNotification: number | string | Notification, newNotification: Notification): void;
}

export type CallBackFunction = (notification: Notification) => void;

export interface Notification {
Expand Down Expand Up @@ -69,7 +61,7 @@ declare namespace NotificationSystem {
ActionWrapper?: WrapperStyle | undefined;
}

export interface Attributes extends React.ClassAttributes<System> {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props can't determine the ref type for class components. Needed to move code around so that NotificationSystem correctly extends a React.Component.

export interface Attributes {
noAnimation?: boolean | undefined;
style?: Style | boolean | undefined;
allowHTML?: boolean | undefined;
Expand All @@ -81,5 +73,13 @@ declare namespace NotificationSystem {
}


declare var NotificationSystem: React.ClassicComponentClass<NotificationSystem.Attributes>;
declare class NotificationSystem extends React.Component<NotificationSystem.Attributes, NotificationSystem.State> {
addNotification(notification: NotificationSystem.Notification): NotificationSystem.Notification;
removeNotification(uidOrNotification: number | string | NotificationSystem.Notification): void;
clearNotifications(): void;
editNotification(
uidOrNotification: number | string | NotificationSystem.Notification,
newNotification: NotificationSystem.Notification,
): void;
}
export = NotificationSystem;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import NotificationSystem = require('react-notification-system');

class MyComponent extends React.Component {
private notificationSystem: NotificationSystem.System = null;
private notificationSystem: NotificationSystem = null;

private notification: NotificationSystem.Notification = {
title: 'Notification title',
Expand Down Expand Up @@ -54,7 +54,7 @@ class MyComponent extends React.Component {
}
};

const ref = (instance: NotificationSystem.System) => {
const ref = (instance: NotificationSystem) => {
this.notificationSystem = instance
}

Expand Down