gor181 / react-notification-system-redux

Redux wrapper for react-notification-system
MIT License
324 stars 59 forks source link

How to import in typescript #37

Closed vincaslt closed 7 years ago

vincaslt commented 7 years ago

Using these types: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/07352da21a909cb2786a40106aad1fea562d5973/types/react-notification-system-redux/index.d.ts

I see that the element Notifications is exported both as a class and as a namespace. I cannot figure out how to import the component, because the interpreter always tells me it's ambiguous:

import * as Notifications from 'react-notification-system-redux' <Notifications notifications={notifications} /> <- tells me: [ts] JSX element type 'Notifications' does not have any construct or call signatures.

import Notifications from 'react-notification-system-redux' <- tells me there is no default export

import {Notifications} from 'react-notification-system-redux' <- has no exported member 'Notifications'.

codeaid commented 7 years ago

I'm using @types/react-notification-system-redux and this works without any errors:

import * as Notifications from 'react-notification-system-redux';

export class App extends React.Component<IAppProps, {}> {
    render(): JSX.Element {
        return (
            <Router>
                <div className="layout">
                    <Notifications
                        notifications={notifications}
                    />
                </div>
            </Router>
        );
    }
}
vincaslt commented 7 years ago

Don't remember exactly what the problem was, but I don't seem to have problems with it anymore.