You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Button}from"library";// but doesn't export ButtonProps! oh no!typeButtonProps=React.ComponentProps<typeofButton>;// no problem! grab your own!typeAlertButtonProps=Omit<ButtonProps,"onClick">;// modifyconstAlertButton=(props: AlertButtonProps)=>(<ButtononClick={()=>alert("hello")}{...props}/>);
获取函数返回值
// inside some library - return type { baz: number } is inferred but not exportedfunctionfoo(bar: string){return{baz: 1};}// inside your app, if you need { baz: number }typeFooReturn=ReturnType<typeoffoo>;// { baz: number }
对于更多的“自定义”,
infer
关键字是为此的基本构建块The text was updated successfully, but these errors were encountered: