mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
Made a type to help me use generics as record keys
This commit is contained in:
parent
2c2bcb4de7
commit
e473e4b641
1 changed files with 8 additions and 0 deletions
8
src/utils/types/record-key.ts
Normal file
8
src/utils/types/record-key.ts
Normal 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;
|
Loading…
Reference in a new issue