score:1

interface A {
  propA: string;
}

interface B {
  propB: number;
  propC: boolean;
}

type ABIntersection = A & B;
type ABUnion        = A | B;

function C(props: ABIntersection) {
  const a = fancyPicker<A>(props);
  const b = fancyPicker<B>(props);
  console.log(a);
  // prints "{ propA: "some string" }"
  console.log(b);
  // prints "{ propB: 42, propC: false }" 
}

const testValue = { propA: "some string", propB: 42, propC: false, propD: "never see this" };
C(testValue);


Related Query

More Query from same tag