Answer the question
In order to leave comments, you need to log in
Why is the variable type lost when nested operations are performed?
There are two interfaces
interface IBigItem {
fieldName: string
label: string
default?: boolean
...еще много полей
}
interface ISmallItem {
fieldName: string
label: string
default: boolean
}
const columns: IBigItem[]
const selected: ISmallItem = columns.map(column => ({
fieldName: column.fieldName,
label: column.label,
default: column.default ?? false
}))
const newColumns = selected.map(selectedColumn => {
const newColumn = columns.find(columnDef => columnDef.fieldName === selectedColumn.fieldName)
newColumn.default = selectedColumn.default
return newColumn
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question