Docs update
This commit is contained in:
20
src/types.ts
Normal file
20
src/types.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Return keys on a type as an array of strings
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* type Person = {
|
||||
* firstName: string;
|
||||
* lastName: string;
|
||||
* age: number;
|
||||
* }
|
||||
*
|
||||
* const keys = typeKeys<Person>();
|
||||
* console.log(keys); // Output: ["firstName", "lastName", "age"]
|
||||
* ```
|
||||
*
|
||||
* @return {Array<keyof T>} Available keys
|
||||
*/
|
||||
export function tyoeKeys<T extends object>() {
|
||||
return Object.keys(<T>{}) as Array<keyof T>;
|
||||
}
|
Reference in New Issue
Block a user