Types - Type 'string' is not assignable to type xxx
See original GitHub issueDo you want to request a feature or report a bug? bug with types
What is the current behavior? toast.POSITION.xxx and toast.TYPE.xxx can’t be passed to ToastContainer or toast() ->
Type 'string' is not assignable to type '"info" | "success" | "warning" | "error" | "default" | undefined'.
Type 'string' is not assignable to type '"top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left" | undefined'.
Type 'string' is not assignable to type '"top-right" | "top-center" | "top-left" | "bottom-right" | "bottom-center" | "bottom-left" | undefined'.ts(2322) index.d.ts(48, 5): The expected type comes from property 'position' which is declared here on type 'IntrinsicAttributes & ToastContainerProps & { children?: ReactNode; }'
the same issue (part of it) has already been fixed here - https://github.com/fkhadra/react-toastify/issues/470 - however it looks to me as not solved (in the latest 6.0.5 version) according to this simple codesandbox test - https://codesandbox.io/s/react-toastify-type-mismatch-33ulj?file=/src/index.tsx
import * as React from "react";
import { render } from "react-dom";
import { toast, ToastContainer } from "react-toastify";
const App: React.FunctionComponent<{}> = () => {
function test() {
toast("message", {
type: toast.TYPE.INFO,
position: toast.POSITION.BOTTOM_CENTER
});
}
return (
<ToastContainer
position={toast.POSITION.TOP_CENTER}
type={toast.TYPE.INFO}
/>
);
};
render(<App />, document.getElementById("root"));
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:
https://codesandbox.io/s/react-toastify-type-mismatch-33ulj?file=/src/index.tsx
What is the expected behavior? toast.POSITION.xxx and toast.TYPE.xxx values should be allowed for use in ToastContainer and toast()
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? react-toastify 6.0.5
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top GitHub Comments
The issue should be solved with the release 6.0.7 that I’ve just pushed.
This is solved!!!
Just checked with v6.0.7