Having
export enum PropertyCode {
_D = '_D',
ABCO = 'ABCO',
ACC = 'ACC',
// ... etc
I have a function that should return a Record<PropertyCode, any>
public getProperties(): Record<PropertyCode, any> {
let propertyArray: [PropertyCode, any][] = this.propertyControls?.map(
(x) => [x.value.propertyCode, x.value.value]) ?? [];
return propertyArray // [string, any][] ==>??? Record<PropertyCode, any>
}
I have a compile error :
Type '[PropertyCode, any][]' is missing the following properties from type 'Record<PropertyCode, any>': _D, ABCO, ACC, ACCO, and 255 more.
How should I convert the array to Record, without explicitly filling all 255 enum codes?
Array.prototype.reduce. Please provide reproducible example