简体   繁体   中英

Typescript: How do you add a type declaration to the severity property in React Alert?

I've created a type declaration object for the data that is coming in, but no matter what I seem to try and define as the type for the property "severity", it's upset. What it wants (as shown below) doesn't seem to be an option. I was just wondering if there is a type I can use besides "any" that would work for this ? Or, because it is custom, any is my only option?

Here's what I have that is throwing the below error:

type ticketData = {
  name: string;
  title: string;
  onClose: () => void;
  message: string[];
}

在此处输入图片说明

https://mui.com/components/snackbars/

you have to mention any of these below options for colors provided by muiAlert:

name: 'success' | 'info' | 'warning' | 'error' | undefined

check api Link - https://mui.com/api/alert/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM