3 Replies
dopeinc
dopeinc•17mo ago
Question is in comment at the bottom
whatplan
whatplan•17mo 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
dopeinc•17mo 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