2

So I was working on a type and wanted to get recommendation of an object's keys, and if I wanted to use another key, the type could fallback to a string type.

I know that the union type with a string basically is the every possible string, so no recommendations are given.

But why while this approach does not work string | keyof Database the following gives the desired result (string & {}) | DatabaseKeys> ?

Find more complete example in TS playground.

konsalex
  • 425
  • 5
  • 15
  • See [the answer to the linked question](https://stackoverflow.com/a/61048124/2887218) for an explanation – jcalz Jul 07 '21 at 15:12

0 Answers0