我可以编写一个函数吗
const f = <T extends ???>(x: T) => ...
这样,当且仅当T
没有特定属性时,对它的调用才会编译?我的具体用例是this function:
export declare function withApollo<TProps, TResult = any>(WrappedComponent: React.ComponentType<WithApolloClient<Omit<TProps, "client">>>, operationOptions?: OperationOption<TProps, TResult>): React.ComponentClass<Omit<TProps, "client">>;
我发现类型推断对它的处理很糟糕,需要总是在我们的代码库中提供显式的类型参数.如果我可以指定T
没有"client"
,我可以提供更好的包装器.