question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types - Type 'string' is not assignable to type xxx

See original GitHub issue

Do 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fkhadracommented, Jul 2, 2020

The issue should be solved with the release 6.0.7 that I’ve just pushed.

1reaction
rajeshdecommented, Jul 2, 2020

This is solved!!!

Just checked with v6.0.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Typescript - Argument of type 'string' is not assignable to ...
This line means you'll call setState with one of two types: null or an array of InspectionReportData . You are actually calling it...
Read more >
What is not assignable to parameter of type never error in ...
I get the following TS error: [ts] Argument of type 'string' is not assignable to parameter of type 'never'. What exactly am I...
Read more >
Argument type XXX is not assignable to parameter type Any
1. Create a method with at least one parameter · 2. JSDoc @param {Any} · 3. Call this method with argument of any...
Read more >
Is not assignable to type intrinsicattributes - Kodlogs.net
4:9 Argument of type '" string"' is not assignable to parameter of type 'number'. This is informing you of the particular nature of...
Read more >
type 'react.reactnode' is not assignable to type 'import( - You.com
The types returned by 'render()' are incompatible between these types. Type 'React. ... Type unknown[] is not assignable to type ReactElement<any, string ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found