vrimar / construct-ui

A Mithril.js UI library
https://vrimar.github.io/construct-ui
MIT License
287 stars 23 forks source link

const assertion #68

Closed panoply closed 1 year ago

panoply commented 2 years ago

Hey @vrimar

Hope all is well.

It would be nice if const assertions were applied to the value maps. We need not widen the literal types on these to obtain literal value, for example:

export const Classes = {
  XS: 'cui-xs',
  SM: 'cui-sm',
  LG: 'cui-lg',
  XL: 'cui-xl'
 // .... etc etc
} as const

I tend to reach for these exports rather frequently. Composing additional types from the maps is rather extraneous without assertion. A more elegant approach could be exporting these as const enums because they are removed during compilation but this may result in some refactors across the codebase and in addition require exposure to raw .ts files in the distributed bundle.

vrimar commented 2 years ago

Yeah this makes sense, I'll be pushing an update for this in the next few days!