Preference for Explicit vs. Automated Object Construction in TypeScript

I've got a more generic and subjective code style question regarding the mapping of string literals to other properties. I was curious whether you prefer a very explicit, albeit tedious, construction of objects as seen with aggregateOne in the following snippet or do you prefer snippets that automate this while still being somewhat type-safe such as aggregateTwo. Also, is there something in Effect that would possibly make this easier?
const InfrastructureKind = Schema.Literal(['Manufactory', 'SolarFarm', 'Laboratory'])
const Aggregate = Schema.Struct({
    tiers: Schema.Record({ key: typeof InfrastructureKind.Type, value: Schema.NonNegativeInt })
})
// ...
const [colony] = db
  .select({
    manufactoryTier: coloniesTable.manufactoryTier,
    solarFarmTier: coloniesTable.solarFarmTier,
    laboratoryTier: coloniesTable.laboratoryTier,
  })
  .from(coloniesTable)
  .where(eq(coloniesTable.ownerId, userId))
const aggregateOne = Aggregate.make({
  tiers: {
    Manufactory: colony.manufactoryTier,
    SolarFarm: colony.solarFarmTier,
    Laboratory: colony.laboratoryTier,
  }
})
const aggregateTwo = Aggregate.make({
  tiers: InfrastructureKind.literals.reduce((acc, el) => {
    acc[el] = colony[`${kebabCase(el)}Tier`]
    return acc
  }, {})
})
Was this page helpful?