How to extract a type from a tagged union type in typescript?

Yes it is possible you are very close, you can use the predefined Extract conditional type. You can will need to pass in, as the second argument, a type that can be a base type for the type you are seeking:

type LinkItem = Extract<Item, { type: 'link' }> // will be  { type: "link"; url: string; }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)