#Typescript type to reference key of other property of same type

11 messages · Page 1 of 1 (latest)

trail fog
#

How do I do this?

interface SelectSub<T extends Record<string, any>> {
  subkey: keyof T
  otherThing: T
}

const a: SelectSub = { // want to avoid using <>. Shouldn't it be able to determine what that is?
  subkey: "beans", // should error
  otherThing: {
    banana: 1,
    orange: 2,
  }
}
warped frost
#

Not when you are assigning it to the variable

trail fog
#

So it has to pop out of a function or something

#

The context is I am trying to define an app.config in nuxt, and normal vuetify thing is broken, so I'm trying to go something like

export default defineAppConfig<{ vuetify: VuetifyConfig }>({
  vuetify: {
    defaultTheme: 'eggplant',
    themes: {
      dark: {
        dark: true,
        // did you know vuetify 3 forgot to export these colours
        // even though the documentation says you can do this?
        // colors: {
        //   // primary: colors.blue.darken2,
        //   // accent: colors.grey.darken3,
        //   // secondary: colors.amber.darken3,
        //   // info: colors.teal.lighten1,
        //   // warning: colors.amber.base,
        //   // error: colors.deepOrange.accent4,
        //   // success: colors.green.accent3,
        // }
      },
    },
  },
})

but type it.

I can ignore this and just do defaultTheme: string but there's a part of me that is going "There's a better way!"

trail fog
#

Not sure how to trigger hot-module theme updates but just having to force-reload when this happens is fine.

warped frost
#

Is this vuetify 3?

#

Ah I assume give the comments lmao

#

Are you enjoying it?

trail fog
#

christ on a cracker I have not had to fanagle this kinda horseshit in a while.

Vuetify 3 is "broken" in context of nuxt. I am annoyed.

I am kinda annoyed at intellisense in-regards-to <v-thing> in the template area.

#

I also had to hamfist a module to hide away the vuetify stuff, and I am unsure how to make vuetify respond to changes in appConfig or where the correct place for that is.

#

I am slowly converting an app I had.