0

for example i have this type:type mixed = {k1: string, k2: number}

now i want another type(could be generated from some generic) with only string property type from mixed, like this:

type stringOnly = {k1: string} where k2 from mixed is omitted.

How to do this in typescript? Thanks!

Ymin Hu
  • 619
  • 6
  • 7
  • 1
    Translating the answer to the other question here yields [this](https://tsplay.dev/KWzrkW) – jcalz Dec 01 '20 at 17:08

1 Answers1

1

If you want to remove a specific property for the new type, you can use Omit:

type stringOnly = Omit<mixed, "k2">;
ljbc1994
  • 2,044
  • 11
  • 13