The idea is to enforce not using certain fields in the object passed to the function, and you can use anything else (that's why the extends)
type ForbiddenFields = 'a' | 'b' | 'c';
type Data = { [K in ForbiddenFields]?: never };
function foobar<T extends Data>(data: T): void {
//...
}
const obj = { x: 1, y: 2 };
foobar(obj); // Type '{ x: 1, y: 2 }' has no properties in common with type Data
Why do I get the
Type '{ x: 1, y: 2 }' has no properties in common with type Data
if the function is just expecting an object extending Data, wouldn't it be the same as saying <T extends {}> but just enforcing that if a ForbiddenField is specified it has to be never -- therefore, can't be there?