feat(types): allow raw_number cells in TableBlock rows - #2737
Conversation
The table-block reference documents that table cells "can have a type of rich_text, raw_text, or raw_number", but TableBlock.rows was typed (RichTextBlock | RawTextElement)[][] — omitting raw_number — and its @description said only "raw_text or rich_text". A valid raw_number table cell (verified in Block Kit Builder) raised a spurious type error. - Add the RawNumberElement composition object (type raw_number, value, text), the same definition the data_table PR (#2638) introduces, so the two share one cell element type. - Add RawNumberElement to TableBlock.rows and correct the @description to match the docs. - Add the first tsd coverage for TableBlock (all three cell types; TableBlock had no type tests before). Closes #2689. Ref: https://docs.slack.dev/reference/block-kit/blocks/table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
🦋 Changeset detectedLatest commit: 3fd2669 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2737 +/- ##
=======================================
Coverage 89.12% 89.12%
=======================================
Files 65 65
Lines 10441 10441
Branches 482 482
=======================================
Hits 9306 9306
Misses 1103 1103
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
The docs list the cell types as "rich_text, raw_text, or raw_number"; align the @description (and the test comment) to that order verbatim. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The doc link points at the table-block reference, so wrap it around `TableBlock` rather than `raw_number`. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
It's an additive minor bump (new RawNumberElement + widened cell union), so the changeset verb should be feat, not fix. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The new RawNumberElement (and the pre-existing RawTextElement) had no direct type coverage — only indirect exercise through TableBlock. Add a composition-objects.test-d.ts with happy/sad-path cases for both raw cell objects. Placed flat in test/ to match blocks.test-d.ts and block-elements.test-d.ts (test/ mirrors src/ only for the events group). Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
left a comment
There was a problem hiding this comment.
💬 Immediate ideas with this change are in comments following-
There was a problem hiding this comment.
🧪 note: This path is adjacent to similar files including:
- blocks.test-d.ts
- block-elements.test-d.ts
And I think we might move these to a separate path similar to how "events" are grouped in a follow up PR!
| /** | ||
| * @description Defines an object containing a numeric value. | ||
| */ | ||
| export interface RawNumberElement { | ||
| /** | ||
| * @description The formatting to use for this numeric object. | ||
| */ | ||
| type: 'raw_number'; | ||
| /** | ||
| * @description The numeric value. | ||
| */ | ||
| value: number; | ||
| /** | ||
| * @description The text used to display the value. The minimum length is 1 character. | ||
| */ | ||
| text: string; | ||
| } |
There was a problem hiding this comment.
🎁 note: Right now this is used for table but #2638 hopes to include this for possible rows too:
🔗 https://docs.slack.dev/reference/block-kit/blocks/data-table-block#schema-raw-number
# Conflicts: # packages/types/test/blocks.test-d.ts
Extend the TableBlock happy-path assertion to include a column_settings array (is_wrapped and align), giving TableBlockColumnSettings its first type coverage alongside the raw_number cell cases. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Summary
This pull request fixes the
TableBlocktype in@slack/typesto allowraw_numbercells, which the table-block reference documents but the type omitted.rich_text,raw_text, orraw_number", butTableBlock.rowswas typed(RichTextBlock | RawTextElement)[][](noraw_number) and its@descriptionsaid only "raw_text or rich_text".RawNumberElementcomposition object (type: 'raw_number',value,text) — the same definition introduced by thedata_tablePR feat(types): add data_table Block Kit block #2638, so the two share one cell element type and whichever lands second drops the duplicate in a trivial merge.RawNumberElementtoTableBlock.rowsand corrects the@descriptionto match the docs.TableBlock(all three cell types);TableBlockpreviously had no type tests.Closes #2689. A working
raw_number-in-tablepayload is in this Block Kit Builder preview (from the issue).Requirements