Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Lodash concat of arrays of nested objects of diffrent types

I want to concatenate 2 arrays of nested objects of different types with lodash concat method. However typescript linter rise error about 2nd array type. My first array is:

[
  {
    Header: '...',
    accessor: '...',
    minWidth: 200,
    Filter: {...},
    filter: {...},
    Aggregated: () => null,
  },
  {
    Header: '...',
    accessor: '...',
    minWidth: 200,
    Filter: {...},
    filter: {...},
    Aggregated: () => null,
  },
  {
    Header: '...',
    accessor: '...',
    minWidth: 200,
    Aggregated: () => null,
  },
  {
    Header: '...',
    accessor: '...',
    minWidth: 200,
  },
  ...
]

Where Filter and filter are big nested objects. My second array is:

[
  {
    Header: '...',
    accessor: '...',
    disableGroupBy: true,
  }
]

I am getting typescript linter error

Type '{ Header: string; accessor: string; disableGroupBy: boolean; }' is missing the following properties from type {...} : minWidth, Filter, filter.

Note that there is no Aggregated property requirement.

Lodash documentation says about concat:

Creates a new array concatenating array with any additional arrays and/or values.

  1. Does it mean I can only concat flat objects or primitive values?
  2. Can I concat only arrays of nested objects of the same types?
  3. Should I use different method?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In this case, it's okay to use lodash's concat.

The reason you're getting Type Error is because TypeScript's trying to infer the type for your second array based on your first array, but this type inference is not always true.

You can either provide your own type here, or just set it as any if you don't care about the type of the returned array

// provide your type here. This type defines the shape of elements in the result array
concat<{Header: string, minwidth: number, ...}>(array1, array2)

// or set it to any
concat<any>(array1, array2)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!