Made a type to help me use generics as record keys

This commit is contained in:
Kir_Antipov 2022-12-26 08:16:10 +00:00
parent 2c2bcb4de7
commit e473e4b641

View file

@ -0,0 +1,8 @@
/**
* Returns `T` if it extends `PropertyKey`; otherwise, returns `never`.
*
* This is useful to lift the constraints from a record key.
*
* @template T - The type to check if it extends `PropertyKey`.
*/
export type RecordKey<T> = T extends PropertyKey ? T : never;