type ExtractKeysByValueType<O, V> = {
    [P in keyof O]: O[P] extends V ? P : never;
}[keyof O]

type PickByValueType<O, V> = Pick<O, ExtractKeysByValueType<O, V>>

type OmitByValueType<O, V> = Omit<O, ExtractKeysByValueType<O, V>>


// Usage:

interface User {
    id: string;
    name: string;
    age: number;
    isAdmin: boolean;
}

// Only the properties in User that are strings
type A = PickByValueType<User, string> // { id: string; name: string }

// Everything but the properties in User that are strings
type B = OmitByValueType<User, string> // { age: number; isAdmin: boolean }