1

I'd like to narrow object's keys to only those with string value. Here's an example:

interface Person {
  id: number;
  name: string;
  address: Address;
}

type onlyKeysWithStingValues = ??? // only the key name should be allowed

Basically I'd like to narrow keyof Person to only those keys with string values. Is it possible?

  • Using the `KeysMatching` type function from [the answer to the other question](https://stackoverflow.com/a/54520829/2887218) gives you [this code](https://tsplay.dev/Wzo91w). – jcalz Oct 06 '21 at 17:38

0 Answers0