I need some help with Typescript Records.
I'm looking for a solution that avoids manually typing keys names as a key type for a Record, but still keeping intelisense for that object.
For example:
import { StyleProp, TextStyle } from 'react-native';//I would like to avoid manually typing dozens of keys here. //Can it somehow automatically fetch keys that are already inside the fonts object?type TFontKeys = | 'title' | 'subtitle' | 'header'///////const fonts: Record<TFontKeys, StyleProp<TextStyle>> = { title: { fontSize: 22, fontWeight: '600', }, subtitle: { fontSize: 16, fontWeight: '600', }, header: { fontSize: 16, fontWeight: '500', marginBottom: 8, }}
I know that I can simply use
Record<string, StyleProp<TextStyle>>
But then I lose intelisense for fonts.properties
If a Record is not made for this, is there anything else that can do this?
Thank you~