Answers for "typescript generic dictionary"

0

typescript generic dictionary

// You should check the source of why you have to force string and number
// Example 1 with Generic with default value

type DefaultSlotType = "something" | "something2"

type PlayerInventory<T extends  string | number = DefaultSlotType> = Record<T, InventorySlotSchema>

// Example 2 without default

type PlayerInventory<T extends  string | number> = Record<T, InventorySlotSchema>

// Example 2 without default and just a string
type PlayerInventory<T extends string> = Record<T, InventorySlotSchema>
Posted by: Guest on October-06-2021

Code answers related to "typescript generic dictionary"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language