Created
April 27, 2022 04:10
-
-
Save nulIptr/7cc0a421a6e91db3336973cae4c07326 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StringOnly<T> = { [K in keyof T as T[K] extends string ? K : never]: T[K] }; | |
function useTable<T extends { name: string }>( | |
records: T[] | |
) { | |
return useTableWithCustomKey(records,'name'); | |
} | |
function useTableForName(records: { name: string }[]) { | |
return useTableWithCustomKey(records,'name'); | |
} | |
function useTableWithCustomKey<T>( | |
records: T[], | |
keyName: keyof StringOnly<T> | |
) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment