I'm new with typescript and try to undertsand how to make type from typeof but there is the problem.
Lets say i have const filter
export const filter = {
filters: {
name: {value: '' , matchMode: ''}
}
}
Then i make FilterType from const filter using typeof
type FilterType = typeof filter
Then i create const myFilter which type is FilterType
export const myFilter: FilterType = {
filters: {name:{value: 'myValue' , // how to make possible to accept number too?
matchMode: 'contains'}} // how to limit matchMode to accept only values 'contain' or 'eq'
}
Everithing forks fine if keys value and matchMode is a string but it doesn't work if a pass number for example, or i would like predefine matchMode and access only if value is contain or 'eq'
How could i achieve this? I suppose it could be done with Generic, but how?