ATProto Browser

ATProto Browser

Experimental browser for the Atmosphere

Post

Template string types can really help you out some times. Good tool to have. Working with a radio group that can only have string values, but I want to make sure they're "numbers".

May 6, 2025, 5:11 PM

Record data

{
  "uri": "at://did:plc:h4qem3f3cz6yvs3r3xvs634g/app.bsky.feed.post/3lojetwnl2s2c",
  "cid": "bafyreidp6f4a4qjohwlkwv3jrpkapb3yjiprrmkzxmkw6rwmyxeyluplze",
  "value": {
    "text": "Template string types can really help you out some times. Good tool to have.\n\nWorking with a radio group that can only have string values, but I want to make sure they're \"numbers\".",
    "$type": "app.bsky.feed.post",
    "embed": {
      "$type": "app.bsky.embed.images",
      "images": [
        {
          "alt": "// Template string types allow us to be more accurate\n// with our types than just `string` here.\ntype NumString = `${number}`\n\n// Use it with selects or radio groups that only\n// accept string values\nconst MILES: OptionItem<NumString>[] = [\n  { label: t('5 miles'), value: '5' },\n  { label: t('10 miles'), value: '10' },\n  { label: t('25 miles'), value: '25' },\n  { label: t('50 miles'), value: '50' },\n  { label: t('100 miles'), value: '100' },\n];",
          "image": {
            "$type": "blob",
            "ref": {
              "$link": "bafkreicttkn4ouu3cq62lkpwqqg52guzjltpsqcmvf52iywsrsr6qbgaey"
            },
            "mimeType": "image/jpeg",
            "size": 442579
          },
          "aspectRatio": {
            "width": 1388,
            "height": 846
          }
        }
      ]
    },
    "langs": [
      "en"
    ],
    "createdAt": "2025-05-06T17:11:07.261Z"
  }
}