3 Replies
dopeinc
dopeincOP•2y ago
Question is in comment at the bottom
whatplan
whatplan•2y ago
type TestArray = typeof managedProperties;
type InferTypeOfKeyValue = TestArray[number]['value'];
type TestArray = typeof managedProperties;
type InferTypeOfKeyValue = TestArray[number]['value'];
is this what your looking for?
dopeinc
dopeincOP•2y ago
Yeah I went this way but it was more complicated ended up doing this , its safe but unsafe but works 🙂 :
type ManagedProperty<T> = {
id: string
type: 'location' | 'status' | 'users' | 'fileType'
order: number
value: T
onSubmit?: (data: LocationData) => void
}

interface Props<T extends readonly ManagedProperty<unknown>[]> {
managedProperties: T
}
type ManagedProperty<T> = {
id: string
type: 'location' | 'status' | 'users' | 'fileType'
order: number
value: T
onSubmit?: (data: LocationData) => void
}

interface Props<T extends readonly ManagedProperty<unknown>[]> {
managedProperties: T
}
the former didn't understand that my array of managedProperties could have multple values of different type it would always match the first one I have some playground if ever you want them
Want results from more Discord servers?
Add your server