1

Click here for StackBlitz Example

Problem:

Why can't I have Foo without Bar or more specifically how do I change this to allow either or both, but complain about anything else?

TS Warning confusing me....

enter image description here

index.ts

enter image description here

service.ts

enter image description here

serviceConfig.ts

enter image description here

Presumably my Service Method - dataWithValidKeys: { [key in validKeys]: any } is wrong

MagicLuckyCat
  • 324
  • 2
  • 5
  • 19
  • 1
    Does this answer your question? [typescript interface require one of two properties to exist](https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist) – Joe Sep 16 '21 at 10:40
  • Thanks Joe, this did help steer me towards utility types documentation. – MagicLuckyCat Sep 16 '21 at 11:10

1 Answers1

0

Solution: "Partial" was missing...

Constructs a type with all properties of Type set to optional. This utility will return a type that represents all subsets of a given type.

See all utility types

enter image description here

Voila!

enter image description here

Working version

MagicLuckyCat
  • 324
  • 2
  • 5
  • 19