type PickByType<T, U> = {
[K in keyof T as T[K] extends U ? K : never]: T[K]
}
Solution by MohammadArasteh #35271
// your answers
type PickByType<T, U> = {
[key in keyof T as T[key] extends U ? key : never]: T[key]
}
Solution by AndreGeng #34758
// your answers
type PickByType<T, U> = {
[K in keyof T as T[K] extends U ? K : never]: T[K]
}
Solution by gobielJonathan #34526
type PickByType<T extends object, U> = {
[K in keyof T as T[K] extends U ? K : never]: U
}
Solution by ouzexi #34046
type PickByType<T, U> = {
[key in keyof T as T[key] extends U ? key : never]: T[key]
}
Solution by ZhipengYang0605 #33109
type PickByType<T, U> = {
[K in keyof T as (T[K] extends U ? K : never)]: T[K]
};
Solution by dimitriiy #33005
// your answers
type PickByType<T, U> = {[K in keyof T as T[K] extends U ? K : never]: T[K]}
Solution by pea-sys #32775
type PickByType<T extends Record<keyof T, unknown>, U> = {
[K in keyof T as T[K] extends U ? K : never]: T[K]
}
Solution by ZhulinskiiDanil #32729
type PickByType<T extends Record<string, unknown>, PT extends unknown> = {
[K in keyof T as T[K] extends PT ? never : K]: T[K]
}
Solution by ZhulinskiiDanil #32715
type PickByType<T extends object, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] }
Solution by dev-hobin #32492
type PickByType<T, U> = { [P in keyof T as T[P] extends U ? P : never]: T[P] }
Solution by rkamely #32064
type PickByType<T, U> = {
[K in keyof T as T[K] extends U ? K : never]: T[K]
}
Solution by vipulpathak113 #31886
type PickByType<O, T> = {
[K in keyof O as O[K] extends T ? K : never]: T
}
Solution by ricky-fn #31841
type PickByType<T, U> = {
[P in keyof T as T[P] extends U ? P : never]: T[P]
}
Solution by Chan-Yuxi #30954
type PickByType<T, U> = {
[key in keyof T as T[key] extends U ? key : never] : U
}
Solution by kai-phan #30750
type PickByType<T, U> = {
[Key in keyof T as T[Key] extends U ? Key : never]: T[Key]
}
Solution by maximallain #30443
type PickByType<T, U> = {
[Prop in keyof T as T[Prop] extends U ? Prop : never] : T[Prop]
}
Just index key remapping and check the value matches U, ez.
Solution by fredski02 #29527
type PickByType<T extends object, E> = {
[k in keyof T as T[k] extends E ? k : never]: T[k]
}
type OnlyBoolean = PickByType<{
name: string;
count: 1;
isReadonly: boolean;
isEnable: boolean;
}, boolean>;
Solution by sundial-dreams #29481
Solution:
type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] };
Solution by DmitriiBr #29288
type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K: never ]: T[K] };
Solution by MrRENGE #29272
type PickByType<T, U> = {
[Key in keyof T as T[Key] extends U ? Key : never]: T[Key]
}
Solution by hajeonghun #28827
type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K]; };
Solution by DoubleWoodLin #28689
// your answers
type PickByType<T extends object, U> = {[key in keyof T as T[key] extends U ? key : never]: T[key]}
Solution by wjddlsy #27819
// your answers
// ============= Your Code Here =============
type PickByType<T, U> = {
[ K in keyof T as T[K] extends U ? K : never ]: T[K]
}
Solution by ixiaolong2023 #27798
type PickByType<T, U> = {
[K in keyof T as T[K] extends U ? K : never]: T[K]
}
Solution by jjswifty #27622
type PickByType<T, U> = { [K in keyof T as T[K] extends U ? K : never]: T[K] }
Solution by mrdulin #27523
// your answers
type PickByType<T, U> = {[P in keyof T as T[P] extends U ? P : never] : T[P]}
Solution by GreattitJY #27260
// your answers
type PickByType<T, U> = { [P in keyof T as T[P] extends U ? P : never]: T[P] }
Solution by daiki-skm #27200
type PickByType<T extends object, U> = {
[P in keyof T as T[P] extends U ? P : never]: T[P]
}
Solution by 8471919 #27178
type PickByType<T, K> = { [Key in keyof T as T[Key] extends K ? Key : never] : T[Key]}
Solution by vuongManabie #27096