Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Toast type #91

Closed
ohueter opened this issue Jun 21, 2021 · 3 comments · Fixed by #103 · May be fixed by vAHiD55555/proxy-provider-converter#4
Closed

Export Toast type #91

ohueter opened this issue Jun 21, 2021 · 3 comments · Fixed by #103 · May be fixed by vAHiD55555/proxy-provider-converter#4

Comments

@ohueter
Copy link

ohueter commented Jun 21, 2021

It would be great if the Toast type was exported from the library.

I'm using toast with a function argument like this (simplified example):

import toast, { Toast /* error, not exported */ } from "react-hot-toast";

const Message = (message: string, t: any /* this cannot be typed, should be `t: Toast` */) => (
  <>
    <div>{message}</div>
    <CloseButton onClick={() => toast.dismiss(t.id)} />
  </>
);

toast.success((t) => Message(message, t))

which is not possible in TypeScript due to the missing export. In fact, I would appreciate exporting all types declared in types.d.ts :-)

@kephail
Copy link

kephail commented Jun 21, 2021

I would also appreciate this.

@sachinraja
Copy link

Just saying, you can import Toast from react-hot-toast/dist/core/types. But it would be nice for it to be exported from react-hot-toast.

@jrmyio
Copy link

jrmyio commented Jul 22, 2021

Just saying, you can import Toast from react-hot-toast/dist/core/types. But it would be nice for it to be exported from react-hot-toast.

This works , however if "importsNotUsedAsValues": "error" is set in tsconfig.json, this will throw an error on import { CSSProperties } from 'react';:
This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'.ts(1371)

I guess thats because the types file is imported directly, or import { CSSProperties } from 'react';: should become import type { CSSProperties } from 'react';:

On a side-note, would also be great to have access to Renderable type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants