interaction-kit icon indicating copy to clipboard operation
interaction-kit copied to clipboard

Type Work

Open IanMitchell opened this issue 3 years ago • 2 comments

Using alii's type ideas

IanMitchell avatar Jan 31 '22 05:01 IanMitchell

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/ianmitchell/interaction-kit/EF4FBvbMVvW5YdZpvoAws7zSCoGw
✅ Preview: https://interaction-kit-git-autocomplete-types-ianmitchell1.vercel.app

vercel[bot] avatar Jan 31 '22 05:01 vercel[bot]

Test script for this:

import { NumberInput, SlashChoiceList, SlashCommand, StringInput } from "packages/interaction-kit/src";

const choices = SlashChoiceList.create({
  key: "choice value",
  label: "value",
  term: "phrase"
});

const command = new SlashCommand({
  name: "test",
  description: "test",
  options: [
    new StringInput({ name: "string", required: true, description: "required string" }),
    new StringInput({ name: "choice", required: true, description: "string input", choices }),
    new NumberInput({ name: "numeral", description: "number input" })
  ],
  handler: (interaction) => {
    interaction.options.string // should return value | undefined
    interaction.options.numeral // should return value | undefined


    // which is better (watch for name conflicts):
    interaction.options.choice === choices.key // returning comparing strings
    interaction.options.choice // returns keyof choices


    interaction.options
  })
})

just stick it in the top level. Includes some notes for later, pausing this to get the new types out

IanMitchell avatar Mar 03 '22 04:03 IanMitchell