我需要从具有特殊界面的对象中提取一些键(例如,IProps)。 我想从函数“a”返回唯一属性,它具有ISubProps接口
interface IProps<T> {
value: T;
}
interface ISubProps {
[index: string]: IProps<any>;
}
interface IAnyProps {
[index: string]: string | object | boolean | number | symbol;
}
function a<A extends ISubProps, B extends IAnyProps>(props: A & B): A { // Here !!!
return null as any;
}
a({
b: "hi", // error, "b" is not assignable to IProps<any>
});