Reactjs rest隐式地具有类型any,因为它没有类型注释,并且在其自己的初始值设定项中直接或间接引用

Reactjs rest隐式地具有类型any,因为它没有类型注释,并且在其自己的初始值设定项中直接或间接引用,reactjs,typescript,react-router,Reactjs,Typescript,React Router,所以我尝试使用react router 4和Typescript创建一个私有路由。这是我的密码: type PrivateRouteProps<T> = T & { component: any, authRequired: boolean }; function PrivateRoute({ component: Component, authRequired, ...rest }: PrivateRouteProps<typeof rest>) { ret

所以我尝试使用react router 4和Typescript创建一个私有路由。这是我的密码:

type PrivateRouteProps<T> = T & { component: any, authRequired: boolean };

function PrivateRoute({ component: Component, authRequired, ...rest }: PrivateRouteProps<typeof rest>) {
 return (
    <Route
        {...rest}
        render={props => authRequired === true
            ? <Layout><Component {...props} /></Layout>
            : <Redirect to={{ pathname: '/home', state: { from: props.location } }} />}
    />
 );
}
type PrivateRouteProps=T&{component:any,authRequired:boolean};
函数PrivateRoute({component:component,authRequired,…rest}:PrivateRouteProps){
返回(
authRequired==true
? 
: }
/>
);
}
我对PrivateRoute函数中的…rest参数有问题,它给出了错误:

“rest”隐式具有类型“any”,因为它没有类型注释,并且在其自己的初始值设定项中直接或间接引用


我已经查看了typescript文档以进行对象分解,但我似乎找不到解决方案,我认为您无法执行rest类型,因为它不知道rest类型是什么