#Remove key from interface when ....

4 messages · Page 1 of 1 (latest)

swift temple
#

I have a type

type GetArgumentsType<T extends CreateSlashCommand['options']> = {
  [K in keyof T]: 
    T[K]['required'] extends true ? ArgType<T[K]['type']> : Partial<ArgType<T[K]['type']>>
};

Is it possible to do something like this if T[K]['type'] === ApplicationCommandOptionTypes.SubCommand remove K from interface and using recursion trigger GetArgumentsType<T[K]['options']>??

#

I have following example

#
      'user': {
        type: ApplicationCommandOptionTypes.SubCommand,
        description: 'test',
        options: {
          'gg': { 
            description: "Example", 
            type: ApplicationCommandOptionTypes.User 
          }
        },
      },``` here i want to have `arg.gg` and it will return `ArgType<T[K]['type']>` now i need to do arg.user.gg
#
      'user': {
        type: ApplicationCommandOptionTypes.User,
        description: 'test',
      },```
In this example works fine , but while including Subcommand's this dont work as it should